mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-14 20:44:11 +02:00
Fix rows_where() crash when offset is given without limit
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.
This commit is contained in:
parent
6a456830ca
commit
72b7d469a4
2 changed files with 11 additions and 0 deletions
|
|
@ -70,6 +70,13 @@ def test_rows_where_offset_limit(fresh_db, offset, limit, expected):
|
|||
]
|
||||
|
||||
|
||||
def test_rows_where_offset_without_limit(fresh_db):
|
||||
table = fresh_db["rows"]
|
||||
table.insert_all([{"id": id} for id in range(1, 6)], pk="id")
|
||||
ids = [r["id"] for r in table.rows_where(offset=2, order_by="id")]
|
||||
assert ids == [3, 4, 5]
|
||||
|
||||
|
||||
def test_pks_and_rows_where_rowid(fresh_db):
|
||||
table = fresh_db["rowid_table"]
|
||||
table.insert_all({"number": i + 10} for i in range(3))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue