Skip to content

Commit

Permalink
fix ilike performance, make conditional (#221)
Browse files Browse the repository at this point in the history
Co-authored-by: Drini Cami <cdrini@gmail.com>
  • Loading branch information
mekarpeles and cdrini authored Jun 5, 2024
1 parent 83eb7b8 commit d918e18
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions infogami/infobase/dbstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ def process(c, ordering_func=None):
# Raise StopIteration to indicate empty result.
raise StopIteration
c.value = metadata.id
if c.op == '~':
op = Literal('ILIKE')
if c.op in ['~', '~i']:
op = Literal('ILIKE' if c.op == '~i' else 'LIKE')
# Asterisks as part of the author's name query from patron input are escaped in Open Library
# so they don't become % wild card searches. E.g. an author styled as "Muñ*z" shouldn't have
# their "*" become a wild card. Other wild cards added by code should be converted to %, though.
Expand Down
2 changes: 1 addition & 1 deletion infogami/infobase/readquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def parse_key(key):
>>> parse_key('foo!=')
('foo', '!=')
"""
operators = ["!=", "=", "<", "<=", ">=", ">", "~"]
operators = ["!=", "=", "<", "<=", ">=", ">", "~", "~i"]
operator = "="
for op in operators:
if key.endswith(op):
Expand Down

0 comments on commit d918e18

Please sign in to comment.