From 2a4da7eba2c6d7b34d7560d9c2cf53a12c4dcc6c Mon Sep 17 00:00:00 2001 From: Ronni Skansing Date: Sat, 28 Feb 2026 01:02:17 +0100 Subject: [PATCH] dead code Signed-off-by: Ronni Skansing --- backend/repository/utils.go | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/backend/repository/utils.go b/backend/repository/utils.go index ebb7b52..b5c406f 100644 --- a/backend/repository/utils.go +++ b/backend/repository/utils.go @@ -66,36 +66,6 @@ func WithOrderBy(db *gorm.DB, orderBy string, desc bool, allowed ...string) (*go return db.Order(orderBy + " COLLATE NOCASE DESC"), nil } -func WithOrderByOnTable(db *gorm.DB, table string, orderBy string, desc bool, allowed ...string) (*gorm.DB, error) { - if orderBy == "" { - return db, nil - } - // only check default columns if no allowed columns are provided - if _, ok := defaultAllowdColumns[orderBy]; !ok && len(allowed) == 0 { - return db, fmt.Errorf("invalid column: %s", orderBy) - } - for _, allowedOrderBy := range allowed { - if !slices.Contains(allowed, orderBy) { - return db, fmt.Errorf("invalid column: %s", allowedOrderBy) - } - } - - // TODO this ruins all indexes performance but is a quick fix to work for all databases - // to ensure that the order by is case insensitive - // the real solution is to use a case insensitive collation - // but these differ per database, another option would be LOWER indexes for some columns however this is also not ideal - if !desc { - return db.Order( - //fmt.Sprintf("LOWER(`%s`.`%s`) ASC", table, orderBy), - fmt.Sprintf("LOWER(`%s`.`%s`) COLLATE NOCAS ASC", table, orderBy), - ), nil - } - return db.Order( - //fmt.Sprintf("LOWER(`%s`.`%s`) DESC", table, orderBy), - fmt.Sprintf("LOWER(`%s`.`%s`) NO COLLATE DESC", table, orderBy), - ), nil -} - func assignTableToColumn(table, column string) string { // if the column already contains a dot, it is already formatted if strings.Contains(column, ".") {