From 87b9549ff4a711d720604d2c186a8c83cc3d38c5 Mon Sep 17 00:00:00 2001 From: Rahul Shirsat Date: Fri, 26 Feb 2021 13:23:07 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20encoding=20issue=20when=20database=20en?= =?UTF-8?q?coding=20set=20to=C2=A0SQL=5FASCII=20and=20name=20of=20the=20co?= =?UTF-8?q?lumn=20is=20in=20ASCII=20character.=20Fixes=20#6018?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en_US/release_notes_5_1.rst | 1 + web/pgadmin/tools/sqleditor/__init__.py | 4 +++- .../tools/sqleditor/tests/test_encoding_charset.py | 7 +++++++ .../tools/sqleditor/tests/test_sql_ascii_encoding.py | 8 ++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/en_US/release_notes_5_1.rst b/docs/en_US/release_notes_5_1.rst index ababce617..b9565d89e 100644 --- a/docs/en_US/release_notes_5_1.rst +++ b/docs/en_US/release_notes_5_1.rst @@ -19,4 +19,5 @@ Bug fixes | `Issue #4959 `_ - Fixed an issue where the properties tab for collection nodes is unresponsive after switching the tabs. | `Issue #5073 `_ - Fixed an issue where the Save button is enabled for functions/procedures by default when open the properties dialog. +| `Issue #6018 `_ - Fixed encoding issue when database encoding set to SQL_ASCII and name of the column is in ASCII character. | `Issue #6159 `_ - Ensure that the user should be able to kill the session from Dashboard if the user has a 'pg_signal_backend' role. diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index c8ee43c3d..e0817e2c0 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -453,7 +453,9 @@ def poll(trans_id): # Using characters %, (, ) in the argument names is not # supported in psycopg2 col_info['pgadmin_alias'] = \ - re.sub("[%()]+", "|", col_name) + re.sub("[%()]+", "|", col_name).\ + encode('unicode_escape').decode('utf-8') + session_obj['columns_info'] = columns # status of async_fetchmany_2darray is True and result is none diff --git a/web/pgadmin/tools/sqleditor/tests/test_encoding_charset.py b/web/pgadmin/tools/sqleditor/tests/test_encoding_charset.py index a0964cce3..c68c5fbbd 100644 --- a/web/pgadmin/tools/sqleditor/tests/test_encoding_charset.py +++ b/web/pgadmin/tools/sqleditor/tests/test_encoding_charset.py @@ -45,6 +45,13 @@ class TestEncodingCharset(BaseTestGenerator): lc_collate='C', test_str='Tif' )), + ( + 'With Encoding SQL_ASCII (additional test)', + dict( + db_encoding='SQL_ASCII', + lc_collate='C', + test_str='ü' + )), ( 'With Encoding LATIN1', dict( diff --git a/web/pgadmin/tools/sqleditor/tests/test_sql_ascii_encoding.py b/web/pgadmin/tools/sqleditor/tests/test_sql_ascii_encoding.py index a71dfaad0..e25769a9c 100644 --- a/web/pgadmin/tools/sqleditor/tests/test_sql_ascii_encoding.py +++ b/web/pgadmin/tools/sqleditor/tests/test_sql_ascii_encoding.py @@ -55,6 +55,14 @@ class TestSQLASCIIEncoding(BaseTestGenerator): lc_collate='C', test_str='Blob: \xf4\xa5\xa3\xa5' )), + ( + 'Test SQL_ASCII data with blob string & ascii table name', + dict( + table_name='ü', + db_encoding='SQL_ASCII', + lc_collate='C', + test_str='Blob: \xf4\xa5\xa3\xa5' + )), ] def setUp(self):