From 564594f3c8d1d1d109eddd7a13fd210565febdb7 Mon Sep 17 00:00:00 2001 From: Grieve Date: Thu, 14 Nov 2024 16:19:43 +0800 Subject: [PATCH] fix(mssql): use nvarchar to avoid non ascii be question mark --- ibis/backends/mssql/__init__.py | 2 +- ibis/backends/mssql/tests/test_client.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ibis/backends/mssql/__init__.py b/ibis/backends/mssql/__init__.py index c640f58e8001..cdaa985ff545 100644 --- a/ibis/backends/mssql/__init__.py +++ b/ibis/backends/mssql/__init__.py @@ -328,7 +328,7 @@ def _get_schema_using_query(self, query: str) -> sch.Schema: scale, error_number, error_message - FROM sys.dm_exec_describe_first_result_set({tsql}, NULL, 0) + FROM sys.dm_exec_describe_first_result_set(N{tsql}, NULL, 0) ORDER BY column_ordinal """ with self._safe_raw_sql(query) as cur: diff --git a/ibis/backends/mssql/tests/test_client.py b/ibis/backends/mssql/tests/test_client.py index 5db3665027d9..d252ed9d9e29 100644 --- a/ibis/backends/mssql/tests/test_client.py +++ b/ibis/backends/mssql/tests/test_client.py @@ -311,3 +311,11 @@ def test_escape_special_characters(): assert test_func("1bis}Testing!") == "{1bis}}Testing!}" assert test_func("{R;3G1/8Al2AniRye") == "{{R;3G1/8Al2AniRye}" assert test_func("{R;3G1/8Al2AniRye}") == "{{R;3G1/8Al2AniRye}}}" + + +def test_non_ascii_column_name(con): + expr = con.sql("SELECT 1 AS [калона]") + schema = expr.schema() + names = schema.names + assert len(names) == 1 + assert names[0] == "калона"