Skip to content

Commit 5d1f6db

Browse files
fix(app): fix SQL query w/ enum for python 3.11 (#6557)
## Summary Python 3.11 has a wonderfully devious breaking change where _sometimes_ using enum classes that inherit from `str` or `int` do not work the same way as they do in 3.10 when used within string formatting/interpolation. This breaks the new gallery sort queries. The fix is to use `order_dir.value` instead of `order_dir` in the query. This was not an issue during development because the feature was developed w/ python 3.10. ## Related Issues / Discussions Thanks to @JPPhoto for reporting and troubleshooting: https://discord.com/channels/1020123559063990373/1149513625321603162/1256211815982039173 ## QA Instructions JP's fancy python 3.11 system should work on this PR. ## Merge Plan n/a ## Checklist - [x] _The PR has a short but descriptive title, suitable for a changelog_ - [ ] _Tests added / updated (if applicable)_ - [ ] _Documentation added / updated (if applicable)_
2 parents 10076fb + f9961ec commit 5d1f6db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

invokeai/app/services/image_records/image_records_sqlite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ def get_many(
213213

214214
if starred_first:
215215
query_pagination = f"""--sql
216-
ORDER BY images.starred DESC, images.created_at {order_dir} LIMIT ? OFFSET ?
216+
ORDER BY images.starred DESC, images.created_at {order_dir.value} LIMIT ? OFFSET ?
217217
"""
218218
else:
219219
query_pagination = f"""--sql
220-
ORDER BY images.created_at {order_dir} LIMIT ? OFFSET ?
220+
ORDER BY images.created_at {order_dir.value} LIMIT ? OFFSET ?
221221
"""
222222

223223
# Final images query with pagination

0 commit comments

Comments
 (0)