Skip to content

Commit

Permalink
changed lower to upper because iexact uses UPPER
Browse files Browse the repository at this point in the history
  • Loading branch information
barrydaniels-nl committed Jan 21, 2025
1 parent 2c952c0 commit c9f6c16
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/dso_api/dynamic_api/filters/lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def as_sql(self, compiler, connection):
# Allow field__not=value to return NULL fields too.
if field_type in ["CharField", "TextField"]:
return (
f"({lhs}) IS NULL OR LOWER({lhs}) != LOWER({rhs}))",
f"({lhs}) IS NULL OR UPPER({lhs}) != UPPER({rhs}))",
list(lhs_params + lhs_params)
+ [rhs.lower() if isinstance(rhs, str) else rhs for rhs in rhs_params],
+ [rhs.upper() if isinstance(rhs, str) else rhs for rhs in rhs_params],
)
else:
return (
Expand All @@ -65,8 +65,8 @@ def as_sql(self, compiler, connection):
return f"{lhs} IS NOT NULL", lhs_params
else:
if field_type in ["CharField", "TextField"]:
return f"LOWER({lhs}) != LOWER({rhs})", list(lhs_params) + [
rhs.lower() if isinstance(rhs, str) else rhs for rhs in rhs_params
return f"UPPER({lhs}) != UPPER({rhs})", list(lhs_params) + [
rhs.upper() if isinstance(rhs, str) else rhs for rhs in rhs_params
]
else:
return f"{lhs} != {rhs}", list(lhs_params) + rhs_params
Expand All @@ -88,7 +88,7 @@ def as_sql(self, compiler, connection):

lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
return f"LOWER({lhs}) LIKE {rhs}", lhs_params + [rhs.lower() for rhs in rhs_params]
return f"UPPER({lhs}) LIKE {rhs}", lhs_params + [rhs.upper() for rhs in rhs_params]

def get_db_prep_lookup(self, value, connection):
"""Apply the wildcard logic to the right-hand-side value"""
Expand Down Expand Up @@ -117,4 +117,4 @@ def as_sql(self, compiler, connection):
"""Generate the required SQL."""
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
return f"LOWER({lhs}) = LOWER({rhs})", lhs_params + rhs_params
return f"UPPER({lhs}) = UPPER({rhs})", lhs_params + rhs_params

0 comments on commit c9f6c16

Please sign in to comment.