From 23f9ab93b4f59846839a464bc86e672999af75ca Mon Sep 17 00:00:00 2001 From: Jay Hemnani <193022578+jayhemnani9910@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:44:04 +0530 Subject: [PATCH] Show arrays in Postgres format with the default data formats --- AUTHORS | 1 + changelog.rst | 3 +++ pgcli/main.py | 2 +- tests/test_main.py | 6 ++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index d0b4a5cee..4a1307374 100644 --- a/AUTHORS +++ b/AUTHORS @@ -159,6 +159,7 @@ Contributors: * Pieter Ouwerkerk (pouwerkerk) * VXNCXNX * Wei-Lun Li (b84330808) + * Jay Hemnani * jackwalkerlabs (Codex-assisted) diff --git a/changelog.rst b/changelog.rst index fc362092b..4cecfd515 100644 --- a/changelog.rst +++ b/changelog.rst @@ -16,6 +16,9 @@ Bug fixes: created by ``uv venv``. * Read ``alias_map_file`` as UTF-8 (with or without a BOM) instead of the locale encoding, which made non-ASCII aliases fail on Windows. +* Show array columns in Postgres format (``{a,b}``) with the default + settings. They were shown as Python lists (``['a', 'b']``) unless a + ``float`` format was set in ``[data_formats]``. Internal: --------- diff --git a/pgcli/main.py b/pgcli/main.py index 972b3c670..a96587f29 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -2214,7 +2214,7 @@ def format_status(cur, status): "max_field_width": settings.max_field_width, } if not settings.floatfmt: - output_kwargs["preprocessors"] = (align_decimals,) + output_kwargs["preprocessors"] = (align_decimals, format_arrays) if settings.column_date_formats: output_kwargs["preprocessors"] += (format_timestamps,) diff --git a/tests/test_main.py b/tests/test_main.py index 57ba8afe8..5c9facc8a 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -81,6 +81,12 @@ def test_format_output(): assert list(results) == expected +def test_format_output_arrays_without_float_format(): + settings = OutputSettings(table_format="psql") + results = format_output("", [(["a", "b"],)], ["tags"], "", settings) + assert "| {a,b} |" in list(results) + + def test_column_date_formats(): settings = OutputSettings( table_format="psql",