Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Case Insensitive Query Filters #5162

Open
wants to merge 4 commits into
base: mealie-next
Choose a base branch
from

Conversation

michael-genson
Copy link
Collaborator

What this PR does / why we need it:

(REQUIRED)

This makes all query filters that involve strings case-insensitive. For instance:

  • name = "my recipe" will find a recipe titled "My Recipe"
  • name LIKE "%STEW" will find a recipe titled "Beef Stew"

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #5157

Special notes for your reviewer:

(fill-in or delete this section)

From a pure application standpoint you could argue that there are fringe cases where this would be undesired, but I argue that in a recipe manager you would never want case sensitivity. We already do case insensitivity automatically on ordering anyway:

# queries handle uppercase and lowercase differently, which is undesirable
if isinstance(order_attr.type, sqltypes.String):
order_attr = func.lower(order_attr)

Testing

(fill-in or delete this section)

Added a few tests.

@github-actions github-actions bot added the bugfix label Mar 2, 2025
@michael-genson michael-genson changed the title fix: Case-insesnitive Query Filters fix: Case Insesnitive Query Filters Mar 2, 2025
@michael-genson michael-genson changed the title fix: Case Insesnitive Query Filters fix: Case Insensitive Query Filters Mar 2, 2025
@wsargent
Copy link

wsargent commented Mar 2, 2025

Whoops, yes. Thank you for catching that this is Postgres specific. There's also https://www.postgresql.org/docs/current/citext.html if you want to do it in postgres directly.

@michael-genson
Copy link
Collaborator Author

Ah, that's a nice feature. That would be a good idea if we ever redo tables, though at this point it's safer to just leave it as-is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] REST API search on recipes is not case insensitive
2 participants