From 26fddc3258b276acbb2adfdfa8e4c3d744cf3960 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Thu, 12 Feb 2026 17:23:25 +0800 Subject: [PATCH 01/15] feat(db): case-insensitive LIKE/IN for PostgreSQL --- models/db/common.go | 24 ++++++++++++++---------- models/repo/user_repo.go | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index ea628bf2a0a96..5ef6713ffb282 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -16,23 +16,27 @@ import ( // Handles especially SQLite correctly as UPPER there only transforms ASCII letters. func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { - return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)} + return builder.Expr(key+" LIKE ? COLLATE NOCASE", value) } - return builder.Like{"UPPER(" + key + ")", strings.ToUpper(value)} + if setting.Database.Type.IsPostgreSQL() { + return builder.Expr(key+" ILIKE ?", value) + } + return builder.Like{"LOWER(" + key + ")", strings.ToLower(value)} } // BuildCaseInsensitiveIn returns a condition to check if the given value is in the given values case-insensitively. // Handles especially SQLite correctly as UPPER there only transforms ASCII letters. func BuildCaseInsensitiveIn(key string, values []string) builder.Cond { - uppers := make([]string, 0, len(values)) + if setting.Database.Type.IsPostgreSQL() { + return builder.Expr(key+" ILIKE ANY (ARRAY[?])", values) + } + uppers := make([]string, len(values)) + transform := strings.ToUpper if setting.Database.Type.IsSQLite3() { - for _, value := range values { - uppers = append(uppers, util.ToUpperASCII(value)) - } - } else { - for _, value := range values { - uppers = append(uppers, strings.ToUpper(value)) - } + transform = util.ToUpperASCII + } + for i, value := range values { + uppers[i] = transform(value) } return builder.In("UPPER("+key+")", uppers) diff --git a/models/repo/user_repo.go b/models/repo/user_repo.go index 232087d86594e..08cf964bc8b9e 100644 --- a/models/repo/user_repo.go +++ b/models/repo/user_repo.go @@ -151,7 +151,7 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us func GetIssuePostersWithSearch(ctx context.Context, repo *Repository, isPull bool, search string, isShowFullName bool) ([]*user_model.User, error) { users := make([]*user_model.User, 0, 30) var prefixCond builder.Cond = builder.Like{"lower_name", strings.ToLower(search) + "%"} - if isShowFullName { + if search != "" && isShowFullName { prefixCond = prefixCond.Or(db.BuildCaseInsensitiveLike("full_name", "%"+search+"%")) } From fc15486198cdf8022b189868570d34972ffd18e8 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Thu, 12 Feb 2026 19:41:19 +0800 Subject: [PATCH 02/15] Fix copilot --- models/db/common.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index 5ef6713ffb282..f7f0c30c9ebac 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -12,8 +12,10 @@ import ( "xorm.io/builder" ) -// BuildCaseInsensitiveLike returns a condition to check if the given value is like the given key case-insensitively. -// Handles especially SQLite correctly as UPPER there only transforms ASCII letters. +// BuildCaseInsensitiveLike returns a case-insensitive LIKE condition for the given key and value. +// SQLite uses "COLLATE NOCASE" which is ASCII-aware for case-insensitive matching. +// PostgreSQL uses ILIKE for pattern matching. +// Other databases use LOWER(column) + LOWER(value) for case-insensitive matching. func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { return builder.Expr(key+" LIKE ? COLLATE NOCASE", value) @@ -27,9 +29,6 @@ func BuildCaseInsensitiveLike(key, value string) builder.Cond { // BuildCaseInsensitiveIn returns a condition to check if the given value is in the given values case-insensitively. // Handles especially SQLite correctly as UPPER there only transforms ASCII letters. func BuildCaseInsensitiveIn(key string, values []string) builder.Cond { - if setting.Database.Type.IsPostgreSQL() { - return builder.Expr(key+" ILIKE ANY (ARRAY[?])", values) - } uppers := make([]string, len(values)) transform := strings.ToUpper if setting.Database.Type.IsSQLite3() { From 8ffec35a9de1e9219b90b0b6a6cd2235c5d717f2 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Thu, 12 Feb 2026 21:05:44 +0800 Subject: [PATCH 03/15] fix(db): update BuildCaseInsensitiveLike for SQLite handling --- models/db/common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index f7f0c30c9ebac..0f62f428c44c1 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -13,12 +13,12 @@ import ( ) // BuildCaseInsensitiveLike returns a case-insensitive LIKE condition for the given key and value. -// SQLite uses "COLLATE NOCASE" which is ASCII-aware for case-insensitive matching. +// Handles especially SQLite correctly as UPPER there only transforms ASCII letters. // PostgreSQL uses ILIKE for pattern matching. // Other databases use LOWER(column) + LOWER(value) for case-insensitive matching. func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { - return builder.Expr(key+" LIKE ? COLLATE NOCASE", value) + return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)} } if setting.Database.Type.IsPostgreSQL() { return builder.Expr(key+" ILIKE ?", value) From 2d61b0a905d905e214b38f6aba033bd8cf0fbb4c Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 13 Feb 2026 14:20:20 +0800 Subject: [PATCH 04/15] fix(db): update case-insensitive functions to use LOWER for SQLite --- models/db/common.go | 6 +++--- modules/util/util.go | 10 ++++++++++ modules/util/util_test.go | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index 0f62f428c44c1..8b7320d096014 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -18,7 +18,7 @@ import ( // Other databases use LOWER(column) + LOWER(value) for case-insensitive matching. func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { - return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)} + return builder.Like{"LOWER(" + key + ")", util.ToLowerASCII(value)} } if setting.Database.Type.IsPostgreSQL() { return builder.Expr(key+" ILIKE ?", value) @@ -32,13 +32,13 @@ func BuildCaseInsensitiveIn(key string, values []string) builder.Cond { uppers := make([]string, len(values)) transform := strings.ToUpper if setting.Database.Type.IsSQLite3() { - transform = util.ToUpperASCII + transform = util.ToLowerASCII } for i, value := range values { uppers[i] = transform(value) } - return builder.In("UPPER("+key+")", uppers) + return builder.In("LOWER("+key+")", uppers) } // BuilderDialect returns the xorm.Builder dialect of the engine diff --git a/modules/util/util.go b/modules/util/util.go index f197d4d6a4e49..68f3d53c8d6b2 100644 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -101,6 +101,16 @@ func ToUpperASCII(s string) string { return string(b) } +func ToLowerASCII(s string) string { + b := []byte(s) + for i, c := range b { + if 'A' <= c && c <= 'Z' { + b[i] += 'a' - 'A' + } + } + return string(b) +} + // ToTitleCase returns s with all english words capitalized func ToTitleCase(s string) string { // `cases.Title` is not thread-safe, do not use global shared variable for it diff --git a/modules/util/util_test.go b/modules/util/util_test.go index 38876276e3dc3..efd45ce670f5c 100644 --- a/modules/util/util_test.go +++ b/modules/util/util_test.go @@ -207,6 +207,22 @@ func BenchmarkToUpper(b *testing.B) { } } +func TestToLowerASCII(t *testing.T) { + for _, tc := range upperTests { + assert.Equal(t, ToLowerASCII(tc.out), tc.in) + } +} + +func BenchmarkToLower(b *testing.B) { + for _, tc := range upperTests { + b.Run(tc.in, func(b *testing.B) { + for b.Loop() { + ToLowerASCII(tc.out) + } + }) + } +} + func TestToTitleCase(t *testing.T) { assert.Equal(t, `Foo Bar Baz`, ToTitleCase(`foo bar baz`)) assert.Equal(t, `Foo Bar Baz`, ToTitleCase(`FOO BAR BAZ`)) From 04dc671c735e0e1457c7a03972402411497ac0b7 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 13 Feb 2026 14:21:11 +0800 Subject: [PATCH 05/15] fix(db): correct comment in BuildCaseInsensitiveLike for SQLite handling --- models/db/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/db/common.go b/models/db/common.go index 8b7320d096014..28a27f7e2c92f 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -13,7 +13,7 @@ import ( ) // BuildCaseInsensitiveLike returns a case-insensitive LIKE condition for the given key and value. -// Handles especially SQLite correctly as UPPER there only transforms ASCII letters. +// Handles especially SQLite correctly as LOWER there only transforms ASCII letters. // PostgreSQL uses ILIKE for pattern matching. // Other databases use LOWER(column) + LOWER(value) for case-insensitive matching. func BuildCaseInsensitiveLike(key, value string) builder.Cond { From 1781a321c44c89a5789b87a8b0fc22bc087c0752 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 13 Feb 2026 14:24:08 +0800 Subject: [PATCH 06/15] fix(db): update BuildCaseInsensitiveIn to use strings.ToLower for case-insensitive matching --- models/db/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/db/common.go b/models/db/common.go index 28a27f7e2c92f..0942b20ab29c3 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -30,7 +30,7 @@ func BuildCaseInsensitiveLike(key, value string) builder.Cond { // Handles especially SQLite correctly as UPPER there only transforms ASCII letters. func BuildCaseInsensitiveIn(key string, values []string) builder.Cond { uppers := make([]string, len(values)) - transform := strings.ToUpper + transform := strings.ToLower if setting.Database.Type.IsSQLite3() { transform = util.ToLowerASCII } From e37dcc9eb42b5a690c18b3585e1c5dab9f84a6ce Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 13 Feb 2026 14:34:55 +0800 Subject: [PATCH 07/15] fix(util): replace ToUpperASCII with ToLowerASCII and update tests for lowercase conversion --- modules/util/util.go | 12 +---------- modules/util/util_test.go | 42 ++++++++++++--------------------------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/modules/util/util.go b/modules/util/util.go index 68f3d53c8d6b2..d7702439d64d6 100644 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -90,17 +90,7 @@ func CryptoRandomBytes(length int64) ([]byte, error) { return buf, err } -// ToUpperASCII returns s with all ASCII letters mapped to their upper case. -func ToUpperASCII(s string) string { - b := []byte(s) - for i, c := range b { - if 'a' <= c && c <= 'z' { - b[i] -= 'a' - 'A' - } - } - return string(b) -} - +// ToLowerASCII returns s with all ASCII letters mapped to their lower case. func ToLowerASCII(s string) string { b := []byte(s) for i, c := range b { diff --git a/modules/util/util_test.go b/modules/util/util_test.go index efd45ce670f5c..e5027f3ce93ba 100644 --- a/modules/util/util_test.go +++ b/modules/util/util_test.go @@ -178,46 +178,30 @@ type StringTest struct { in, out string } -var upperTests = []StringTest{ +var lowerTests = []StringTest{ {"", ""}, - {"ONLYUPPER", "ONLYUPPER"}, - {"abc", "ABC"}, - {"AbC123", "ABC123"}, - {"azAZ09_", "AZAZ09_"}, - {"longStrinGwitHmixofsmaLLandcAps", "LONGSTRINGWITHMIXOFSMALLANDCAPS"}, - {"long\u0250string\u0250with\u0250nonascii\u2C6Fchars", "LONG\u0250STRING\u0250WITH\u0250NONASCII\u2C6FCHARS"}, + {"onlyupper", "onlyupper"}, + {"abc", "abc"}, + {"AbC123", "abc123"}, + {"azAZ09_", "azaz09_"}, + {"longStrinGwitHmixofsmaLLandcAps", "longstringwithmixofsmallandcaps"}, + {"long\u0250string\u0250with\u0250nonascii\u2C6Fchars", "long\u0250string\u0250with\u0250nonascii\u2C6Fchars"}, {"\u0250\u0250\u0250\u0250\u0250", "\u0250\u0250\u0250\u0250\u0250"}, - {"a\u0080\U0010FFFF", "A\u0080\U0010FFFF"}, - {"lél", "LéL"}, -} - -func TestToUpperASCII(t *testing.T) { - for _, tc := range upperTests { - assert.Equal(t, ToUpperASCII(tc.in), tc.out) - } -} - -func BenchmarkToUpper(b *testing.B) { - for _, tc := range upperTests { - b.Run(tc.in, func(b *testing.B) { - for b.Loop() { - ToUpperASCII(tc.in) - } - }) - } + {"A\u0080\U0010FFFF", "a\u0080\U0010FFFF"}, + {"LéL", "lél"}, } func TestToLowerASCII(t *testing.T) { - for _, tc := range upperTests { - assert.Equal(t, ToLowerASCII(tc.out), tc.in) + for _, tc := range lowerTests { + assert.Equal(t, ToLowerASCII(tc.in), tc.out) } } func BenchmarkToLower(b *testing.B) { - for _, tc := range upperTests { + for _, tc := range lowerTests { b.Run(tc.in, func(b *testing.B) { for b.Loop() { - ToLowerASCII(tc.out) + ToLowerASCII(tc.in) } }) } From f755dd474358fadb449634ad24789e9d9142f3cf Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 13 Feb 2026 14:37:41 +0800 Subject: [PATCH 08/15] fix(tests): update lowerTests for consistent case handling in TestToLowerASCII --- modules/util/util_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/util/util_test.go b/modules/util/util_test.go index e5027f3ce93ba..63b1a7fe8be66 100644 --- a/modules/util/util_test.go +++ b/modules/util/util_test.go @@ -181,11 +181,11 @@ type StringTest struct { var lowerTests = []StringTest{ {"", ""}, {"onlyupper", "onlyupper"}, - {"abc", "abc"}, + {"ABC", "abc"}, {"AbC123", "abc123"}, {"azAZ09_", "azaz09_"}, {"longStrinGwitHmixofsmaLLandcAps", "longstringwithmixofsmallandcaps"}, - {"long\u0250string\u0250with\u0250nonascii\u2C6Fchars", "long\u0250string\u0250with\u0250nonascii\u2C6Fchars"}, + {"LONG\u0250STRING\u0250WITH\u0250NONASCII\u2C6FCHARS", "long\u0250string\u0250with\u0250nonascii\u2C6Fchars"}, {"\u0250\u0250\u0250\u0250\u0250", "\u0250\u0250\u0250\u0250\u0250"}, {"A\u0080\U0010FFFF", "a\u0080\U0010FFFF"}, {"LéL", "lél"}, From 5e7e05b2099100c2c5e3ec2e629afc152801c1ed Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 13 Feb 2026 14:49:36 +0800 Subject: [PATCH 09/15] Copilot recommends removing the use of ilike in PostgreSQL --- models/db/common.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index 0942b20ab29c3..5bc986d791822 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -20,9 +20,6 @@ func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { return builder.Like{"LOWER(" + key + ")", util.ToLowerASCII(value)} } - if setting.Database.Type.IsPostgreSQL() { - return builder.Expr(key+" ILIKE ?", value) - } return builder.Like{"LOWER(" + key + ")", strings.ToLower(value)} } From 43ca0ccbe0f1c5815014aff618ae80c407629b9d Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 13 Feb 2026 15:35:40 +0800 Subject: [PATCH 10/15] Remove PostgreSQL ILIKE comment in common.go Removed comment about PostgreSQL ILIKE usage in BuildCaseInsensitiveLike function. Signed-off-by: Tyrone Yeh --- models/db/common.go | 1 - 1 file changed, 1 deletion(-) diff --git a/models/db/common.go b/models/db/common.go index 5bc986d791822..80e0b344fa851 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -14,7 +14,6 @@ import ( // BuildCaseInsensitiveLike returns a case-insensitive LIKE condition for the given key and value. // Handles especially SQLite correctly as LOWER there only transforms ASCII letters. -// PostgreSQL uses ILIKE for pattern matching. // Other databases use LOWER(column) + LOWER(value) for case-insensitive matching. func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { From db39ca3549e945d2b14ad826a21d1bae5cf40238 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 13 Feb 2026 15:52:48 +0800 Subject: [PATCH 11/15] fix --- models/db/common.go | 6 +++++- modules/util/util_test.go | 9 ++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index 80e0b344fa851..e6c123fa33f93 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -13,8 +13,12 @@ import ( ) // BuildCaseInsensitiveLike returns a case-insensitive LIKE condition for the given key and value. +// Cast the value and the database column value to the same cast to do case-insensitive matching. +// * For SQLite, only cast ASCII chars because it doesn't handle complete Unicode case folding +// * For other databases, the assumption is that they are able to handle complete Unicode case folding correctly // Handles especially SQLite correctly as LOWER there only transforms ASCII letters. // Other databases use LOWER(column) + LOWER(value) for case-insensitive matching. +// Using lower case makes 7% speed improvement than upper case (by Golang's benchmark) func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { return builder.Like{"LOWER(" + key + ")", util.ToLowerASCII(value)} @@ -23,7 +27,7 @@ func BuildCaseInsensitiveLike(key, value string) builder.Cond { } // BuildCaseInsensitiveIn returns a condition to check if the given value is in the given values case-insensitively. -// Handles especially SQLite correctly as UPPER there only transforms ASCII letters. +// See BuildCaseInsensitiveLike for more details func BuildCaseInsensitiveIn(key string, values []string) builder.Cond { uppers := make([]string, len(values)) transform := strings.ToLower diff --git a/modules/util/util_test.go b/modules/util/util_test.go index 63b1a7fe8be66..88680cc3c6206 100644 --- a/modules/util/util_test.go +++ b/modules/util/util_test.go @@ -180,14 +180,9 @@ type StringTest struct { var lowerTests = []StringTest{ {"", ""}, - {"onlyupper", "onlyupper"}, {"ABC", "abc"}, - {"AbC123", "abc123"}, - {"azAZ09_", "azaz09_"}, - {"longStrinGwitHmixofsmaLLandcAps", "longstringwithmixofsmallandcaps"}, - {"LONG\u0250STRING\u0250WITH\u0250NONASCII\u2C6FCHARS", "long\u0250string\u0250with\u0250nonascii\u2C6Fchars"}, - {"\u0250\u0250\u0250\u0250\u0250", "\u0250\u0250\u0250\u0250\u0250"}, - {"A\u0080\U0010FFFF", "a\u0080\U0010FFFF"}, + {"AbC123_", "abc123_"}, + {"LONG\u0250string\u0250WITH\u0250non-ascii\u2C6FCHARS\u0080\uFFFF", "long\u0250string\u0250with\u0250nonascii\u2C6Fchars\u0080\uFFFF"}, {"LéL", "lél"}, } From ddbac8e44c66e1091175e72a9c78340a41215772 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 13 Feb 2026 15:55:38 +0800 Subject: [PATCH 12/15] fix comment --- models/db/common.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index e6c123fa33f93..31ab7d6f00b57 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -14,11 +14,9 @@ import ( // BuildCaseInsensitiveLike returns a case-insensitive LIKE condition for the given key and value. // Cast the value and the database column value to the same cast to do case-insensitive matching. -// * For SQLite, only cast ASCII chars because it doesn't handle complete Unicode case folding -// * For other databases, the assumption is that they are able to handle complete Unicode case folding correctly -// Handles especially SQLite correctly as LOWER there only transforms ASCII letters. -// Other databases use LOWER(column) + LOWER(value) for case-insensitive matching. -// Using lower case makes 7% speed improvement than upper case (by Golang's benchmark) +// * SQLite: only cast ASCII chars because it doesn't handle complete Unicode case folding +// * Other databases: use database's string function, assuming that they are able to handle complete Unicode case folding correctly +// ToLowerASCII is about 7% faster than ToUpperASCII (according to Golang's benchmark) func BuildCaseInsensitiveLike(key, value string) builder.Cond { if setting.Database.Type.IsSQLite3() { return builder.Like{"LOWER(" + key + ")", util.ToLowerASCII(value)} From 0071444847619aa357d2d95f1dc86f4e5a115956 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 13 Feb 2026 15:57:54 +0800 Subject: [PATCH 13/15] fix comment --- models/db/common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index 31ab7d6f00b57..35baff4052231 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -13,11 +13,11 @@ import ( ) // BuildCaseInsensitiveLike returns a case-insensitive LIKE condition for the given key and value. -// Cast the value and the database column value to the same cast to do case-insensitive matching. +// Cast the search value and the database column value to the same case for case-insensitive matching. // * SQLite: only cast ASCII chars because it doesn't handle complete Unicode case folding // * Other databases: use database's string function, assuming that they are able to handle complete Unicode case folding correctly -// ToLowerASCII is about 7% faster than ToUpperASCII (according to Golang's benchmark) func BuildCaseInsensitiveLike(key, value string) builder.Cond { + // ToLowerASCII is about 7% faster than ToUpperASCII (according to Golang's benchmark) if setting.Database.Type.IsSQLite3() { return builder.Like{"LOWER(" + key + ")", util.ToLowerASCII(value)} } From 7f31c02ecac482f70df5f9e96ef87bc9d716b97d Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 13 Feb 2026 16:01:48 +0800 Subject: [PATCH 14/15] fix --- modules/util/util_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/util/util_test.go b/modules/util/util_test.go index 88680cc3c6206..fd677f5c11c7c 100644 --- a/modules/util/util_test.go +++ b/modules/util/util_test.go @@ -182,8 +182,9 @@ var lowerTests = []StringTest{ {"", ""}, {"ABC", "abc"}, {"AbC123_", "abc123_"}, - {"LONG\u0250string\u0250WITH\u0250non-ascii\u2C6FCHARS\u0080\uFFFF", "long\u0250string\u0250with\u0250nonascii\u2C6Fchars\u0080\uFFFF"}, - {"LéL", "lél"}, + {"LONG\u0250string\u0250WITH\u0250non-ascii\u2C6FCHARS\u0080\uFFFF", "long\u0250string\u0250with\u0250non-ascii\u2C6Fchars\u0080\uFFFF"}, + {"lél", "lél"}, + {"LÉL", "lÉl"}, } func TestToLowerASCII(t *testing.T) { From 945f3a2baaed67229640cd325ec88fc3bfb1f7fd Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 13 Feb 2026 16:04:50 +0800 Subject: [PATCH 15/15] fix var name --- models/db/common.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/models/db/common.go b/models/db/common.go index 35baff4052231..b3c43f8b6263d 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -27,16 +27,15 @@ func BuildCaseInsensitiveLike(key, value string) builder.Cond { // BuildCaseInsensitiveIn returns a condition to check if the given value is in the given values case-insensitively. // See BuildCaseInsensitiveLike for more details func BuildCaseInsensitiveIn(key string, values []string) builder.Cond { - uppers := make([]string, len(values)) - transform := strings.ToLower + incaseValues := make([]string, len(values)) + caseCast := strings.ToLower if setting.Database.Type.IsSQLite3() { - transform = util.ToLowerASCII + caseCast = util.ToLowerASCII } for i, value := range values { - uppers[i] = transform(value) + incaseValues[i] = caseCast(value) } - - return builder.In("LOWER("+key+")", uppers) + return builder.In("LOWER("+key+")", incaseValues) } // BuilderDialect returns the xorm.Builder dialect of the engine