Skip to content

Commit

Permalink
Merge pull request dbcli#1321 from dbcli/j-bennet/1320-redshift-statu…
Browse files Browse the repository at this point in the history
…s-rows

Add rowcount to status returned from redshift.
  • Loading branch information
amjith authored Mar 2, 2022
2 parents 7423f9d + f0ab01c commit 43263a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion changelog.rst
Original file line number Diff line number Diff line change
@@ -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)
==================
Expand Down
10 changes: 9 additions & 1 deletion pgcli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "-",
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 43263a9

Please sign in to comment.