mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
fix: Case Insensitive Query Filters (#5162)
This commit is contained in:
parent
4ecfd8ec78
commit
ad59e653da
2 changed files with 43 additions and 2 deletions
|
@ -216,6 +216,29 @@ def test_pagination_filter_basic(query_units: tuple[RepositoryUnit, IngredientUn
|
|||
assert unit_results[0].id == unit_2.id
|
||||
|
||||
|
||||
def test_pagination_filter_string_case_insensitive(
|
||||
query_units: tuple[RepositoryUnit, IngredientUnit, IngredientUnit, IngredientUnit],
|
||||
):
|
||||
units_repo, *units = query_units
|
||||
target_unit = random.choice(units)
|
||||
|
||||
query = PaginationQuery(page=1, per_page=-1, query_filter=f'name="{target_unit.name.upper()}"')
|
||||
unit_results = units_repo.page_all(query).items
|
||||
assert len(unit_results) == 1
|
||||
assert unit_results[0].id == target_unit.id
|
||||
|
||||
upper_unit = units_repo.create(
|
||||
SaveIngredientUnit(name="mIxEd-CaSe uNiT", group_id=units_repo.group_id, use_abbreviation=True)
|
||||
)
|
||||
try:
|
||||
query = PaginationQuery(page=1, per_page=-1, query_filter=f'name="{upper_unit.name.lower()}"')
|
||||
unit_results = units_repo.page_all(query).items
|
||||
assert len(unit_results) == 1
|
||||
assert unit_results[0].id == upper_unit.id
|
||||
finally:
|
||||
units_repo.delete(upper_unit.id)
|
||||
|
||||
|
||||
def test_pagination_filter_null(unique_user: TestUser):
|
||||
database = unique_user.repos
|
||||
recipe_not_made_1 = database.recipes.create(
|
||||
|
@ -425,6 +448,18 @@ def test_pagination_filter_like(query_units: tuple[RepositoryUnit, IngredientUni
|
|||
assert unit_3.id in result_ids
|
||||
|
||||
|
||||
def test_pagination_filter_like_case_insensitive(
|
||||
query_units: tuple[RepositoryUnit, IngredientUnit, IngredientUnit, IngredientUnit],
|
||||
):
|
||||
units_repo, unit_1, *_ = query_units
|
||||
|
||||
query = PaginationQuery(page=1, per_page=-1, query_filter=r'name LIKE "%EST UNIT 1%"')
|
||||
unit_results = units_repo.page_all(query).items
|
||||
|
||||
assert len(unit_results) == 1
|
||||
assert unit_results[0].id == unit_1.id
|
||||
|
||||
|
||||
def test_pagination_filter_keyword_namespace_conflict(unique_user: TestUser):
|
||||
database = unique_user.repos
|
||||
recipe_rating_1 = database.recipes.create(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue