mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-11 19:14:10 +02:00
fix: allow rows_where(offset=...) without limit
Emit LIMIT -1 when using OFFSET alone (issue #816)
This commit is contained in:
parent
6a456830ca
commit
3d10633a50
1 changed files with 6 additions and 0 deletions
|
|
@ -2003,6 +2003,9 @@ class Queryable:
|
|||
if limit is not None:
|
||||
sql += f" limit {limit}"
|
||||
if offset is not None:
|
||||
# SQLite requires LIMIT when OFFSET is used (issue #816).
|
||||
if limit is None:
|
||||
sql += " limit -1"
|
||||
sql += f" offset {offset}"
|
||||
cursor = self.db.execute(sql, where_args or [])
|
||||
columns = dedupe_keys(c[0] for c in cursor.description)
|
||||
|
|
@ -3594,6 +3597,9 @@ class Table(Queryable):
|
|||
if limit is not None:
|
||||
limit_offset += f" limit {limit}"
|
||||
if offset is not None:
|
||||
# SQLite requires LIMIT when OFFSET is used (issue #816).
|
||||
if limit is None and " limit " not in limit_offset:
|
||||
limit_offset += " limit -1"
|
||||
limit_offset += f" offset {offset}"
|
||||
return sql.format(
|
||||
dbtable=quote_identifier(self.name),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue