diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index 045f19273..b684662ec 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -2488,10 +2488,10 @@ def rows( sql += " where " + where if order: sql += " order by " + order - if limit: + if limit is not None: sql += f" limit {limit}" if offset: - if not limit: + if limit is None: sql += " limit -1" sql += f" offset {offset}" ctx.invoke( diff --git a/tests/test_cli.py b/tests/test_cli.py index 0e44c16b9..bd16240af 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1184,6 +1184,8 @@ def test_query_memory_does_not_create_file(tmpdir): ["-c", "name", "--limit", "1", "--offset", "1"], '[{"name": "Pancakes"}]', ), + (["--limit", "0"], "[]"), + (["--limit", "0", "--offset", "1"], "[]"), # --offset without --limit ( ["-c", "name", "--offset", "1"],