1
0
Fork 0

fix explain output when running with auto-vertical-output or max_width (#1396)

This commit is contained in:
Andy Schoenberger 2023-02-27 18:20:59 -05:00 committed by GitHub
parent 0a502accfc
commit 8ef5392fd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -20,6 +20,7 @@ Bug fixes:
* Fix \ev not producing a correctly quoted "schema"."view"
* Fix 'invalid connection option "dsn"' ([issue 1373](https://github.com/dbcli/pgcli/issues/1373)).
* Fix explain mode when used with `expand`, `auto_expand`, or `--explain-vertical-output` ([issue 1393](https://github.com/dbcli/pgcli/issues/1393)).
3.5.0 (2022/09/15):
===================

View File

@ -10,7 +10,8 @@ class ExplainOutputFormatter:
self.max_width = max_width
def format_output(self, cur, headers, **output_kwargs):
(data,) = cur.fetchone()
# explain query results should always contain 1 row each
[(data,)] = list(cur)
explain_list = json.loads(data)
visualizer = Visualizer(self.max_width)
for explain in explain_list:

View File

@ -1602,7 +1602,8 @@ def format_output(title, cur, headers, status, settings, explain_mode=False):
first_line = next(formatted)
formatted = itertools.chain([first_line], formatted)
if (
not expanded
not explain_mode
and not expanded
and max_width
and len(strip_ansi(first_line)) > max_width
and headers