Skip to content

Commit

Permalink
fix: ordering for api (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
camarm-dev committed Dec 14, 2024
1 parent 005670e commit 8e73ae9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def fetch_autocomplete(query: str, limit: bool = False, page: int = 0):
lock.acquire(True)
if limit:
response = cursor.execute(
"SELECT word FROM dictionary WHERE indexed LIKE ? + '%' ORDER BY word COLLATE NOCASE ASC LIMIT 5", (query,)).fetchall()
"SELECT word FROM dictionary WHERE indexed LIKE ? ORDER BY lower(word) ASC LIMIT 5", (query + '%',)).fetchall()
else:
response = cursor.execute(
"SELECT word FROM dictionary WHERE indexed LIKE ? + '%' ORDER BY word COLLATE NOCASE ASC LIMIT 50 OFFSET ?", (query, page * 50)).fetchall()
"SELECT word FROM dictionary WHERE indexed LIKE ? ORDER BY lower(word) ASC LIMIT 50 OFFSET ?", (query + '%', page * 50)).fetchall()
return list(map(lambda row: row[0], response))


Expand Down

0 comments on commit 8e73ae9

Please sign in to comment.