sqlite-utils/sqlite_utils
ethanhawkes-gif 43d5d3331f
Emit LIMIT -1 when offset is used without limit (#821)
* Emit LIMIT -1 when offset is used without limit, closes #816

SQLite requires a LIMIT clause to appear before OFFSET, so passing offset
without limit generated invalid SQL such as:

    select * from "t" offset 2

which raised OperationalError: near "2": syntax error.

A negative limit means "no upper bound" in SQLite, so "limit -1 offset N"
returns all rows from position N onwards.

Fixed in three places that build LIMIT/OFFSET SQL:

- Queryable.rows_where() - also covers pks_and_rows_where()
- Table.search_sql() - also covers search()
- the "sqlite-utils rows" CLI command

* Remove duplicate comments

---------

Co-authored-by: ethanhawkes-gif <259455325+ethanhawkes-gif@users.noreply.github.com>
2026-08-11 22:52:43 -07:00
..
__init__.py Fixes for Ruff>=0.16.0 (#814) 2026-07-25 14:53:12 -07:00
__main__.py Support 'python -m sqlite_utils', closes #368 2022-01-08 18:33:22 -08:00
cli.py Emit LIMIT -1 when offset is used without limit (#821) 2026-08-11 22:52:43 -07:00
create_table_parser.py Preserve column before/after comments through .transform() 2026-08-11 22:45:00 -07:00
db.py Emit LIMIT -1 when offset is used without limit (#821) 2026-08-11 22:52:43 -07:00
hookspecs.py Fixes for Ruff>=0.16.0 (#814) 2026-07-25 14:53:12 -07:00
migrations.py Fixes for Ruff>=0.16.0 (#814) 2026-07-25 14:53:12 -07:00
plugins.py Fixes for Ruff>=0.16.0 (#814) 2026-07-25 14:53:12 -07:00
py.typed py.typed file so mypy picks up the types, closes #331 2021-11-14 15:21:04 -08:00
recipes.py Fixes for Ruff>=0.16.0 (#814) 2026-07-25 14:53:12 -07:00
utils.py Fixes for Ruff>=0.16.0 (#814) 2026-07-25 14:53:12 -07:00