Skip to content

Commit

Permalink
Fix markup escaping errors in snow sql command (#1227)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-turbaszek committed Jun 19, 2024
1 parent 635a080 commit a7a8411
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* Improved error message in `snow spcs image-registry login` when docker is not installed.
* Improved detection of conflicts between artifact rules for native application projects
* Fixed URL generation for applications, streamlits, and notebooks that use a quoted identifier with spaces.
* Fixes markup escaping errors in `snow sql` that may occur when users use unintentionally markup-like escape tags.

# v2.4.0
## Backward incompatibility
Expand Down
3 changes: 3 additions & 0 deletions src/snowflake/cli/app/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
# ensure we do not break URLs that wrap lines
get_console().soft_wrap = True

# Disable markup to avoid escaping errors
get_console()._markup = False # noqa: SLF001


class CustomJSONEncoder(JSONEncoder):
"""Custom JSON encoder handling serialization of non-standard types"""
Expand Down
23 changes: 23 additions & 0 deletions tests/output/test_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ def test_single_collection_result(capsys, mock_cursor):
)


def test_print_markup_tags_in_output_do_not_raise_errors(capsys, mock_cursor):
output_data = QueryResult(
mock_cursor(
columns=["CONCAT('[INST]','FOO', 'TRANSCRIPT','[/INST]')"],
rows=[
("[INST]footranscript[/INST]",),
],
)
)
print_result(output_data, output_format=OutputFormat.TABLE)

assert get_output(capsys) == dedent(
"""\
SELECT A MOCK QUERY
+------------------------------------------------+
| CONCAT('[INST]','FOO', 'TRANSCRIPT','[/INST]') |
|------------------------------------------------|
| [INST]footranscript[/INST] |
+------------------------------------------------+
"""
)


def test_print_multi_results_table(capsys, _create_mock_cursor):
output_data = MultipleResults(
[
Expand Down

0 comments on commit a7a8411

Please sign in to comment.