diff options
author | Tyrone Yeh <siryeh@gmail.com> | 2022-07-29 00:58:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 18:58:04 +0200 |
commit | 8e3da0e27fd6da138b34b4a758c48f1d5e73df1f (patch) | |
tree | dc1fa84185839070c4fd6420a3f522fa4674d25f /models/db/common.go | |
parent | 2c108d20baa2b2fd0816ad2dfb3429d49a422f4e (diff) | |
download | gitea-8e3da0e27fd6da138b34b4a758c48f1d5e73df1f.tar.gz gitea-8e3da0e27fd6da138b34b4a758c48f1d5e73df1f.zip |
Modify milestone search keywords to be case insensitive again (#20513)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/db/common.go')
-rw-r--r-- | models/db/common.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/models/db/common.go b/models/db/common.go new file mode 100644 index 0000000000..1a59a8b5c6 --- /dev/null +++ b/models/db/common.go @@ -0,0 +1,23 @@ +// Copyright 2022 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package db + +import ( + "strings" + + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" + + "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. +func BuildCaseInsensitiveLike(key, value string) builder.Cond { + if setting.Database.UseSQLite3 { + return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)} + } + return builder.Like{"UPPER(" + key + ")", strings.ToUpper(value)} +} |