Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Features
Bug Fixes
---------
* Revert suppression of warnings when `sqlglotrs` is installed (fixed upstream).
* Update `cli_helpers` to v2.12.0, fixing a `preserve_whitespace` bug with `tabulate`.


Internal
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"sqlparse>=0.3.0,<0.6.0",
"sqlglot[c] ~= 30.0.0",
"configobj ~= 5.0.9",
"cli_helpers[styles] ~= 2.11.0",
"cli_helpers[styles] ~= 2.12.0",
"wcwidth ~= 0.6.0",
"pyperclip ~= 1.11.0",
"pycryptodomex ~= 3.23.0",
Expand Down
24 changes: 24 additions & 0 deletions test/test_tabular_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

"""Test the sql output adapter."""

import os
from textwrap import dedent

from cli_helpers.utils import strip_ansi
from pymysql.constants import FIELD_TYPE
import pytest

from mycli.main import MyCli
from mycli.packages.sqlresult import SQLResult
from test.utils import HOST, PASSWORD, PORT, USER, dbtest

default_config_file = os.path.join(os.path.dirname(__file__), "myclirc")


@pytest.fixture
def mycli():
Expand Down Expand Up @@ -152,3 +156,23 @@ def description(self):
output = mycli.format_sqlresult(SQLResult(header=header, rows=FakeCursor(), postamble=postamble))
actual = "\n".join(output)
assert actual.endswith(postamble)


def test_tabulate_output_preserves_multiline_whitespace(monkeypatch, tmp_path):
monkeypatch.setenv("HOME", str(tmp_path))
mycli = MyCli(myclirc=default_config_file)
mycli.helpers_style = None
mycli.helpers_warnings_style = None

assert list(mycli.change_table_format("ascii")) == [SQLResult(status="Changed table format to ascii")]

output = mycli.format_sqlresult(SQLResult(header=["text"], rows=[[" one\n two\nthree"]]))

assert strip_ansi("\n".join(output)) == dedent("""\
+------------+
| text |
+------------+
| one |
| two |
| three |
+------------+""")
Loading