From 2eef64c8ce3ef537323df91bce1b523a25e33395 Mon Sep 17 00:00:00 2001 From: Irina Truong Date: Tue, 1 Mar 2022 20:02:31 -0800 Subject: [PATCH 1/3] Add rowcount to status returned from redshift. --- pgcli/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pgcli/main.py b/pgcli/main.py index 43e3fc85d..4b57f53ca 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -1547,6 +1547,14 @@ def format_arrays(data, headers, **_): return data, headers + def format_status(cur, status): + # redshift does not return rowcount as part of status. + # See https://github.com/dbcli/pgcli/issues/1320 + if cur and hasattr(cur, 'rowcount') and cur.rowcount is not None: + if status and not status.endswith(str(cur.rowcount)): + status += " %s" % cur.rowcount + return status + output_kwargs = { "sep_title": "RECORD {n}", "sep_character": "-", @@ -1619,7 +1627,7 @@ def format_arrays(data, headers, **_): # Only print the status if it's not None and we are not producing CSV if status and table_format != "csv": - output = itertools.chain(output, [status]) + output = itertools.chain(output, [format_status(cur, status)]) return output From 00bed0bdad6fe98c05a954ed1ea5164b660a1dd9 Mon Sep 17 00:00:00 2001 From: Irina Truong Date: Tue, 1 Mar 2022 20:15:05 -0800 Subject: [PATCH 2/3] Black. --- pgcli/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgcli/main.py b/pgcli/main.py index 4b57f53ca..2d7edfa00 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -1550,7 +1550,7 @@ def format_arrays(data, headers, **_): def format_status(cur, status): # redshift does not return rowcount as part of status. # See https://github.com/dbcli/pgcli/issues/1320 - if cur and hasattr(cur, 'rowcount') and cur.rowcount is not None: + if cur and hasattr(cur, "rowcount") and cur.rowcount is not None: if status and not status.endswith(str(cur.rowcount)): status += " %s" % cur.rowcount return status From f0ab01c11765d19e17bf651e682c33f2db7aa61a Mon Sep 17 00:00:00 2001 From: Irina Truong Date: Tue, 1 Mar 2022 20:19:51 -0800 Subject: [PATCH 3/3] Changelog. --- changelog.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog.rst b/changelog.rst index 1f0bc595a..05ba05286 100644 --- a/changelog.rst +++ b/changelog.rst @@ -1,7 +1,10 @@ TBD === -* [List new changes here]. +Bug fixes: +---------- + +* Fix the bug with Redshift not displaying wor count in status ([related issue](https://github.com/dbcli/pgcli/issues/1320)). 3.4.0 (2022/02/21) ==================