Too pythonic formatting for array typed columns
Description
The format of array types is too pythonic - includes the u'' prefix for strings, types for datetimes/decimals, etc. Need to format all the elements of the array the same way as they are formatted if they were outside of the array:
Example:
Actual:
xxxdb> select '{"1","2"}'::text[];
+--------------+
| text |
|--------------|
| [u'1', u'2'] |
+--------------+
xxxdb> select '{"2018-01-01"}'::timestamp[];
+---------------------------------------+
| timestamp |
|---------------------------------------|
| [datetime.datetime(2018, 1, 1, 0, 0)] |
+---------------------------------------+
Expected:
xxxdb=> select '{"1","2"}'::text[];
text
-------
{1,2}
xxxdb=> select '{"2018-01-01"}'::timestamp[];
timestamp
-------------------------
{"2018-01-01 00:00:00"}
Your environment
$ pgcli -v
Version: 1.8.2
$ /usr/bin/python -V
Python 2.7.10
$ brew info pgcli
pgcli: stable 1.8.2 (bottled)
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.3
BuildVersion: 17D47
xxxdb> select version();
+----------------------------------------------------------------------------------------------------------+
| version |
|----------------------------------------------------------------------------------------------------------|
| PostgreSQL 9.6.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16), 64-bit |
+----------------------------------------------------------------------------------------------------------+
I traced through the code a bit and cli_helper's tabular output code is at fault. TabularOutputFormatter._get_type() doesn't check for lists and ends up falling through to the text type. It probably needs to be expanded to check for sequence-like types such as lists.
This issue is very old. I cannot reproduce the problem with the latest version of pgcli (4.0.1):
> select '{"1","2"}'::text[];
+------------+
| text |
|------------|
| ['1', '2'] |
+------------+
> select '{"2018-01-01"}'::timestamp[];
+-------------------------+
| timestamp |
|-------------------------|
| ['2018-01-01 00:00:00'] |
+-------------------------+
I guess that the bug has been fixed. I am thus closing this issue.