Skip to content

Keep SQL errors visible under -t/--tuples-only - #1649

Open
DiegoDAF wants to merge 1 commit into
dbcli:mainfrom
DiegoDAF:upstream/tuples-only-errors
Open

DiegoDAF wants to merge 1 commit into
dbcli:mainfrom
DiegoDAF:upstream/tuples-only-errors

Conversation

@DiegoDAF

Copy link
Copy Markdown
Contributor

With -t a failed statement prints nothing at all. The error is printed in place of the status footer, and -t suppresses that footer:

$ pgcli -t -c "select nope"; echo $?
0
$ psql -t -c "select nope"
ERROR:  column "nope" does not exist

Under -t the error now goes to stderr, so stdout still carries only rows, as with psql -t. Output without -t is unchanged.

Tests: a pytest against a live server that fails without the change, a guard that a good query under -t writes nothing to stderr, and a behave scenario that runs pgcli -t -c with stdout and stderr captured apart (there was no behave coverage of -t yet).

The exit status of -c on a failed statement (0, where psql exits 1) is left for a separate change.

The error of a failed statement is printed in the status footer's
place, and -t suppresses that footer, so with -t a broken query printed
nothing at all. For example `pgcli -t -c "select nope"` gives no output
and exits 0, where `psql -t -c "select nope"` prints the error on
stderr.

Under -t the error now goes to stderr, so stdout still carries only
rows, as with psql -t. Output without -t is unchanged.

Tested against a live server: a pytest that fails without the change
(the error reaches stderr and not the rows), a guard that a good query
under -t writes nothing to stderr, and a behave scenario that runs
pgcli -t -c with stdout and stderr captured apart.
DiegoDAF added a commit to DiegoDAF/pgcli.daf that referenced this pull request Oct 14, 2026
DiegoDAF added a commit to DiegoDAF/pgcli.daf that referenced this pull request Oct 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant