From 500a6c4566e6eb228658253c4631858f51cfc51d Mon Sep 17 00:00:00 2001 From: ranjithkumar200621-arch <235286672+ranjithkumar200621-arch@users.noreply.github.com> Date: Tue, 1 Dec 2026 20:28:07 +0530 Subject: [PATCH] Keep empty --execute arguments out of stdin mode --- CHANGELOG.md | 1 + litecli/main.py | 2 +- tests/test_main.py | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d91317..2557091 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Bug Fixes - Expand `~` in configured log file paths before opening the log. +- Treat an empty `--execute` argument as a no-op instead of reading SQL from stdin. ### Internal diff --git a/litecli/main.py b/litecli/main.py index fa732c3..d5711c1 100644 --- a/litecli/main.py +++ b/litecli/main.py @@ -969,7 +969,7 @@ def cli( litecli.logger.debug("Launch Params: \n\tdatabase: %r", database) # --execute argument - if execute: + if execute is not None: try: if csv: litecli.formatter.format_name = "csv" diff --git a/tests/test_main.py b/tests/test_main.py index 21ad5b6..0277e93 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -48,6 +48,14 @@ def test_execute_arg(executor): assert expected in result.output +@dbtest +def test_empty_execute_arg_does_not_read_stdin(executor): + result = CliRunner().invoke(cli, args=CLI_ARGS + ["--execute", ""], input="SELECT 42 AS from_stdin;") + + assert result.exit_code == 0, result.output + assert "from_stdin" not in result.output + + @dbtest def test_execute_arg_with_table(executor): run(executor, "create table test (a text)")