diff --git a/mycli/main.py b/mycli/main.py index 9514f613..c4fd6d30 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -1408,7 +1408,11 @@ def format_output( output_kwargs['missing_value'] = null_string if use_formatter.format_name not in sql_format.supported_formats: - output_kwargs["preprocessors"] = (preprocessors.align_decimals,) + # will run before preprocessors defined as part of the format in cli_helpers + output_kwargs["preprocessors"] = ( + preprocessors.convert_to_undecoded_string, + preprocessors.align_decimals, + ) if title: # Only print the title if it's not None. output = itertools.chain(output, [title]) diff --git a/pyproject.toml b/pyproject.toml index d48f5a89..8bbe011c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dependencies = [ "sqlparse>=0.3.0,<0.6.0", "sqlglot[rs] == 27.*", "configobj >= 5.0.5", - "cli_helpers[styles] >= 2.8.1", + "cli_helpers[styles] >= 2.9.0", "pyperclip >= 1.8.1", "pycryptodomex", "pyfzf >= 0.3.1", diff --git a/test/test_tabular_output.py b/test/test_tabular_output.py index 48146bbe..2ad234f7 100644 --- a/test/test_tabular_output.py +++ b/test/test_tabular_output.py @@ -112,3 +112,7 @@ def description(self): ('abc', 1, NULL, 10.0e0, X'aa') , ('d', 456, '1', 0.5e0, X'aabb') ;""") + # Test binary output format is a hex string + assert list(mycli.change_table_format("psql")) == [SQLResult(None, None, None, "Changed table format to psql")] + output = mycli.format_output(None, FakeCursor(), headers, False, False) + assert '0xaabb' in '\n'.join(output)