Skip to content

Let auto-expand work in -c/-f mode, where there is no prompt - #1654

Open
DiegoDAF wants to merge 1 commit into
dbcli:mainfrom
DiegoDAF:upstream/auto-expand-without-prompt
Open

DiegoDAF wants to merge 1 commit into
dbcli:mainfrom
DiegoDAF:upstream/auto-expand-without-prompt

Conversation

@DiegoDAF

Copy link
Copy Markdown
Contributor

--auto-vertical-output, \x auto and auto_expand = True in the config break -c and -f (4.7.0+): _evaluate_command() reads the terminal width from self.prompt_app, which those modes never build, so every statement fails with 'NoneType' object has no attribute 'output'. A user with auto_expand = True in the config cannot use -c or -f at all.

Without a prompt the terminal is now asked directly, and only when stdout is a terminal: a pipe or a file gets the plain table whatever its width, which is what psql's \x auto does.

Two tests against a live server; both fail on main with the AttributeError above. test_format_array_output_expanded is red on main before this change (cli-helpers 2.15.2, see #1653).

_evaluate_command() read the terminal width from self.prompt_app, which
-c and -f never build, so --auto-vertical-output, \x auto or auto_expand in
the config failed every statement with "'NoneType' object has no attribute
'output'". A user with auto_expand = True could not use -c or -f at all.

Without a prompt the terminal is asked directly, and only when stdout is a
terminal: psql's \x auto leaves a pipe or a file with the plain table
whatever its width.

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