From 2c6a6a2061fde21fa1dc0b3ef86d130781cc6e38 Mon Sep 17 00:00:00 2001 From: LucioLiu <270205078+LucioLiu@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:56:01 +0800 Subject: [PATCH] Respect an explicit zero limit in the rows command --- sqlite_utils/cli.py | 4 ++-- tests/test_cli.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index c23090283..cd22f58e9 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -2485,10 +2485,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 064026a0b..a52537aca 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"],