Skip to content

feat(db): Improve BuildCaseInsensitiveLike with lowercase#36598

Merged
silverwind merged 17 commits intogo-gitea:mainfrom
tyroneyeh:main_pgCaseInsensitive
Feb 14, 2026
Merged

feat(db): Improve BuildCaseInsensitiveLike with lowercase#36598
silverwind merged 17 commits intogo-gitea:mainfrom
tyroneyeh:main_pgCaseInsensitive

Conversation

@tyroneyeh
Copy link
Copy Markdown
Contributor

@tyroneyeh tyroneyeh commented Feb 12, 2026

Improve BuildCaseInsensitiveLike with lowercase, users are more likely to input lowercase letters, so lowercase letters are used.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 12, 2026
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Feb 12, 2026
@silverwind silverwind requested a review from Copilot February 12, 2026 09:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds PostgreSQL-specific handling for case-insensitive matching in shared DB query helpers, and tightens a user search condition to avoid unnecessary full-name matching when the search term is empty.

Changes:

  • Update BuildCaseInsensitiveLike to use SQLite COLLATE NOCASE, PostgreSQL ILIKE, and LOWER(...) fallback for other DBs.
  • Add a PostgreSQL-specific implementation for BuildCaseInsensitiveIn.
  • Avoid adding the full-name OR condition when search == "" in GetIssuePostersWithSearch.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
models/repo/user_repo.go Guards full-name OR condition behind search != "" to avoid redundant full-name matching when search is empty.
models/db/common.go Adds PostgreSQL branches for case-insensitive LIKE/IN and adjusts SQLite LIKE behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tyroneyeh tyroneyeh changed the title feat(db): case-insensitive LIKE/IN for PostgreSQL feat(db): case-insensitive LIKE for PostgreSQL Feb 12, 2026
@tyroneyeh tyroneyeh changed the title feat(db): case-insensitive LIKE for PostgreSQL feat(db): case-insensitive ILIKE for PostgreSQL Feb 12, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 12, 2026
@lunny lunny added the type/enhancement An improvement of existing functionality label Feb 12, 2026
@lunny lunny added this to the 1.26.0 milestone Feb 12, 2026
@silverwind silverwind requested a review from Copilot February 12, 2026 21:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 13, 2026
@silverwind
Copy link
Copy Markdown
Member

Does this fix any open issues? Maybe to a quick search.

@tyroneyeh
Copy link
Copy Markdown
Contributor Author

Does this fix any open issues? Maybe to a quick search.

I did a quick search but couldn't find an existing issue for this.

@silverwind
Copy link
Copy Markdown
Member

Ok, I also double checked in Claude, it did not find any exactly related issue.

@silverwind silverwind enabled auto-merge (squash) February 13, 2026 05:42
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 13, 2026
@wxiaoguang wxiaoguang removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 13, 2026
@wxiaoguang wxiaoguang disabled auto-merge February 13, 2026 05:54
@tyroneyeh tyroneyeh changed the title feat(db): case-insensitive ILIKE for PostgreSQL feat(db): Improve BuildCaseInsensitiveLike with lowercase Feb 13, 2026
@wxiaoguang
Copy link
Copy Markdown
Contributor

Copilot recommends removing the use of ilike in PostgreSQL

If ILIKE is removed, why we still need this PR? Do you see noticeable performance difference between ToLowerASCII and ToUpperASCII?

@tyroneyeh
Copy link
Copy Markdown
Contributor Author

If ILIKE is removed, why we still need this PR? Do you see noticeable performance difference between ToLowerASCII and ToUpperASCII?

It is anticipated that most of the user input will be in lowercase, which will reduce the case conversion rate.

Removed comment about PostgreSQL ILIKE usage in BuildCaseInsensitiveLike function.

Signed-off-by: Tyrone Yeh <siryeh@gmail.com>
@wxiaoguang
Copy link
Copy Markdown
Contributor

If ILIKE is removed, why we still need this PR? Do you see noticeable performance difference between ToLowerASCII and ToUpperASCII?

It is anticipated that most of the user input will be in lowercase, which will reduce the case conversion rate.

Show me with a real world case, to show that it really brings "noticeable performance" improvement.

@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented Feb 13, 2026

If ILIKE is removed, why we still need this PR? Do you see noticeable performance difference between ToLowerASCII and ToUpperASCII?

It is anticipated that most of the user input will be in lowercase, which will reduce the case conversion rate.

Show me with a real world case, to show that it really brings "noticeable performance" improvement.

You can do benchmark with this:


func BenchmarkCaseCast(b *testing.B) {
	b.Run("ToUpper", func(b *testing.B) {
		for b.Loop() {
			for _, tc := range upperTests {
				ToUpperASCII(tc.in)
			}
		}
	})
	b.Run("ToLower", func(b *testing.B) {
		for b.Loop() {
			for _, tc := range upperTests {
				ToLowerASCII(tc.in)
			}
		}
	})
}

For some long texts like https://www.lipsum.com/ :

BenchmarkCaseCast/ToUpper
BenchmarkCaseCast/ToUpper-12         	  555786	      1991 ns/op
BenchmarkCaseCast/ToLower
BenchmarkCaseCast/ToLower-12         	  601572	      1859 ns/op

@wxiaoguang wxiaoguang marked this pull request as ready for review February 13, 2026 07:55
@wxiaoguang
Copy link
Copy Markdown
Contributor

By the way, you need to re-design the test cases, but not just flip their cases.

image

@tyroneyeh
Copy link
Copy Markdown
Contributor Author

IMG_5119

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Feb 14, 2026
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 14, 2026
@silverwind silverwind enabled auto-merge (squash) February 14, 2026 07:04
@silverwind silverwind merged commit 7a8fe9e into go-gitea:main Feb 14, 2026
24 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 14, 2026
@tyroneyeh tyroneyeh deleted the main_pgCaseInsensitive branch February 14, 2026 08:15
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 14, 2026
…6598)

Improve BuildCaseInsensitiveLike with lowercase, users are more likely
to input lowercase letters, so lowercase letters are used.

---------

Signed-off-by: Tyrone Yeh <siryeh@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 14, 2026
* origin/main: (2555 commits)
  automate updating nix flakes (go-gitea#35641)
  Update AGENTS.md instructions (go-gitea#36627)
  use user id in noreply emails (go-gitea#36550)
  feat(db): Improve BuildCaseInsensitiveLike with lowercase (go-gitea#36598)
  [skip ci] Updated translations via Crowdin
  BUG: Fix workflow run jobs API returning null steps (go-gitea#36603)
  Refactor highlight and diff (go-gitea#36599)
  Fix bug when do LFS GC (go-gitea#36500)
  feature to be able to filter project boards by milestones (go-gitea#36321)
  Update emoji data for Unicode 16 (go-gitea#36596)
  Adapt monaco error matching pattern to recent webpack config change (go-gitea#36533)
  Fix a bug user could change another user's primary email (go-gitea#36586)
  fix(repo-editor): disable Monaco `editContext` to avoid bugs with lost focus (go-gitea#36585)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  ...

# Conflicts:
#	custom/conf/app.example.ini
#	docs/content/administration/config-cheat-sheet.en-us.md
#	docs/content/administration/config-cheat-sheet.zh-cn.md
#	modules/setting/security.go
#	routers/common/errpage.go
#	services/context/api.go
#	services/context/context.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants