fix: tag search never matches on slug name - #1563
Open
ngineer420 wants to merge 1 commit into
Open
Conversation
The search term was formatted into LOWER(%s) and passed as the *value* of the
LIKE, so the function name ended up inside the pattern:
slug_name LIKE '%LOWER(coco)%'
That can never match. Only the display_name clause did any work, and LIKE is
case-sensitive on Postgres, so searching a tag by the name it is written in
returns nothing:
slug_name=Coco -> matches
slug_name=coco -> no match
Tags are lower case by convention, so lower case is what users type, and the
filter appears to report that no such tag exists.
Lower both sides instead. The term normalisation is extracted so it can be
covered by a test without a database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Tag search never matches on
slug_name.In
tagCommonRepo.GetTagPage, the search term is formatted intoLOWER(%s)andpassed as the value of the
LIKE, so the function name ends up inside thepattern rather than being applied to the column:
That can never match. Only the
display_nameclause does any work, andLIKEis case-sensitive on PostgreSQL, so searching for a tag by the name it is
written in returns nothing:
Tags are lower case by convention, so lower case is what people type, and the
tag filter appears to report that no such tag exists.
searchTermForTagso the behaviour canbe covered by a unit test without standing up a database
Reproduced against 2.0.2 on PostgreSQL 18.