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)")