mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-13 04:44:19 +02:00
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>
This commit is contained in:
parent
2d3c6b9a1e
commit
43d5d3331f
5 changed files with 33 additions and 0 deletions
|
|
@ -1183,6 +1183,11 @@ def test_query_memory_does_not_create_file(tmpdir):
|
|||
["-c", "name", "--limit", "1", "--offset", "1"],
|
||||
'[{"name": "Pancakes"}]',
|
||||
),
|
||||
# --offset without --limit
|
||||
(
|
||||
["-c", "name", "--offset", "1"],
|
||||
'[{"name": "Pancakes"}]',
|
||||
),
|
||||
# --where
|
||||
(
|
||||
["-c", "name", "--where", "id = 1"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue