You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common.go 665B

12345678910111213141516171819202122
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package db
  4. import (
  5. "strings"
  6. "code.gitea.io/gitea/modules/setting"
  7. "code.gitea.io/gitea/modules/util"
  8. "xorm.io/builder"
  9. )
  10. // BuildCaseInsensitiveLike returns a condition to check if the given value is like the given key case-insensitively.
  11. // Handles especially SQLite correctly as UPPER there only transforms ASCII letters.
  12. func BuildCaseInsensitiveLike(key, value string) builder.Cond {
  13. if setting.Database.UseSQLite3 {
  14. return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)}
  15. }
  16. return builder.Like{"UPPER(" + key + ")", strings.ToUpper(value)}
  17. }