mirror of https://github.com/dbcli/pgcli
fix explain output when running with auto-vertical-output or max_width (#1396)
This commit is contained in:
parent
0a502accfc
commit
8ef5392fd1
|
@ -20,6 +20,7 @@ Bug fixes:
|
||||||
|
|
||||||
* Fix \ev not producing a correctly quoted "schema"."view"
|
* Fix \ev not producing a correctly quoted "schema"."view"
|
||||||
* Fix 'invalid connection option "dsn"' ([issue 1373](https://github.com/dbcli/pgcli/issues/1373)).
|
* 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):
|
3.5.0 (2022/09/15):
|
||||||
===================
|
===================
|
||||||
|
|
|
@ -10,7 +10,8 @@ class ExplainOutputFormatter:
|
||||||
self.max_width = max_width
|
self.max_width = max_width
|
||||||
|
|
||||||
def format_output(self, cur, headers, **output_kwargs):
|
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)
|
explain_list = json.loads(data)
|
||||||
visualizer = Visualizer(self.max_width)
|
visualizer = Visualizer(self.max_width)
|
||||||
for explain in explain_list:
|
for explain in explain_list:
|
||||||
|
|
|
@ -1602,7 +1602,8 @@ def format_output(title, cur, headers, status, settings, explain_mode=False):
|
||||||
first_line = next(formatted)
|
first_line = next(formatted)
|
||||||
formatted = itertools.chain([first_line], formatted)
|
formatted = itertools.chain([first_line], formatted)
|
||||||
if (
|
if (
|
||||||
not expanded
|
not explain_mode
|
||||||
|
and not expanded
|
||||||
and max_width
|
and max_width
|
||||||
and len(strip_ansi(first_line)) > max_width
|
and len(strip_ansi(first_line)) > max_width
|
||||||
and headers
|
and headers
|
||||||
|
|
Loading…
Reference in New Issue