Skip to content

Fix rows_where() crash when offset is given without limit#817

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-rows-where-offset-without-limit
Open

Fix rows_where() crash when offset is given without limit#817
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-rows-where-offset-without-limit

Conversation

@ikatyal2110

@ikatyal2110 ikatyal2110 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

SQLite requires a LIMIT clause before OFFSET; without one, rows_where(offset=N) generates SELECT … OFFSET N which raises OperationalError: near "N": syntax error. The fix emits LIMIT -1 automatically when offset is set but limit is not, which SQLite treats as "no upper bound". The same pattern is fixed in search_sql(). A regression test is added. Fixes #816


Generated by Claude Code


📚 Documentation preview 📚: https://sqlite-utils--817.org.readthedocs.build/en/817/

SQLite requires LIMIT before OFFSET; omitting it raised OperationalError.
When offset is set and limit is not, emit LIMIT -1 first so the SQL is valid.
Same fix applied to search_sql(). Adds regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rows_where() raises OperationalError when offset is given without limit

1 participant