diff options
author | Amjith Ramanujam <amjith.r@gmail.com> | 2022-03-01 20:28:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-01 20:28:47 -0800 |
commit | 43263a90d260d8b20d90494da7f6696f4435b0c4 (patch) | |
tree | 301c54c1439209dbf6223887869ee783858ab53d | |
parent | 7423f9d239e37da1883d6c5a3bd2baf2c28997a4 (diff) | |
parent | f0ab01c11765d19e17bf651e682c33f2db7aa61a (diff) |
Merge pull request #1321 from dbcli/j-bennet/1320-redshift-status-rows
Add rowcount to status returned from redshift.
-rw-r--r-- | changelog.rst | 5 | ||||
-rw-r--r-- | pgcli/main.py | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/changelog.rst b/changelog.rst index 1f0bc595..05ba0528 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) ================== diff --git a/pgcli/main.py b/pgcli/main.py index 43e3fc85..2d7edfa0 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -1547,6 +1547,14 @@ def format_output(title, cur, headers, status, settings): 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_output(title, cur, headers, status, settings): # 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 |