Skip to content

Commit

Permalink
Merge pull request #217 from scottbarnes/feature/use-ilike-rather-tha…
Browse files Browse the repository at this point in the history
…n-like-for-tilde-search

Feature: `~` uses `ILIKE` rather than `LIKE`
  • Loading branch information
cdrini committed May 22, 2024
2 parents 3a65087 + 0ac15b0 commit 6fd5ca1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion infogami/infobase/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ def initialize(self):
"""Initializes the store for the first time.
This is called before doing the bootstrap.
"""
...

def set_cache(self, cache):
pass
Expand Down
7 changes: 5 additions & 2 deletions infogami/infobase/dbstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,11 @@ def process(c, ordering_func=None):
raise StopIteration
c.value = metadata.id
if c.op == '~':
op = Literal('LIKE')
c.value = c.value.replace('*', '%').replace('_', r'\_')
op = Literal('ILIKE')
# 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.
c.value = r'\*'.join(part.replace('*', '%') for part in c.value.split(r'\*')).replace('_', r'\_')
else:
op = Literal(c.op)

Expand Down

0 comments on commit 6fd5ca1

Please sign in to comment.