Skip to content

Show arrays in Postgres format with the default data formats - #1664

Open
jayhemnani9910 wants to merge 1 commit into
dbcli:mainfrom
jayhemnani9910:keep-array-format-by-default
Open

jayhemnani9910 wants to merge 1 commit into
dbcli:mainfrom
jayhemnani9910:keep-array-format-by-default

Conversation

@jayhemnani9910

Copy link
Copy Markdown

Description

With the shipped config, array columns print as Python lists:

postgres> select id, tags from people order by id;
| 1  | ['a', 'b'] |
| 2  | []         |

format_output sets preprocessors to (format_numbers, format_arrays), then replaces the whole tuple with (align_decimals,) when no float format is set, which is the default (float = "" in pgclirc). That drops format_arrays. Setting float = "g" makes arrays show as {a,b}, so the formatter is there but skipped. It's now kept: (align_decimals, format_arrays).

Tested: new test_format_output_arrays_without_float_format fails without the change; full suite 2680 passed (2679 on main). In a pgcli session against PostgreSQL 17 with an empty pgclirc, the query above now shows {a,b} and {}.

\T csv output has the same Python lists and also writes <null> and space-padded numbers; that part is left alone here.

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install).
  • I verified that my changes work as expected (this may include manually testing them in your local environment, or in other available environments). Cross this out if not relevant (for example, if you're making a documentation change).
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

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