diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index c72505a4..ead100e7 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -1476,14 +1476,19 @@ def query_tool_status(trans_id): if conn and trans_obj and session_obj: status = conn.transaction_status() - return make_json_response( - data={ - 'status': status, - 'message': gettext( - CONNECTION_STATUS_MESSAGE_MAPPING.get(status) - ) - } - ) + if status is not None: + return make_json_response( + data={ + 'status': status, + 'message': gettext( + CONNECTION_STATUS_MESSAGE_MAPPING.get(status) + ) + } + ) + else: + return internal_server_error( + errormsg=gettext("Transaction status check failed.") + ) else: return internal_server_error( errormsg=gettext("Transaction status check failed.") diff --git a/web/pgadmin/utils/driver/psycopg2/connection.py b/web/pgadmin/utils/driver/psycopg2/connection.py index 315631c0..ac85f9dc 100644 --- a/web/pgadmin/utils/driver/psycopg2/connection.py +++ b/web/pgadmin/utils/driver/psycopg2/connection.py @@ -50,6 +50,12 @@ else: _ = gettext +# Replace default ascii encoder with unicode-escape +# which translates characters to unicode format. +# Escape special characters to ASCII based on unicode +encodings['SQL_ASCII'] = 'unicode-escape' +encodings['SQLASCII'] = 'unicode-escape' + # Register global type caster which will be applicable to all connections. register_global_typecasters() diff --git a/web/pgadmin/utils/driver/psycopg2/typecast.py b/web/pgadmin/utils/driver/psycopg2/typecast.py index f1366049..ccebb2f9 100644 --- a/web/pgadmin/utils/driver/psycopg2/typecast.py +++ b/web/pgadmin/utils/driver/psycopg2/typecast.py @@ -164,7 +164,7 @@ def register_global_typecasters(): def register_string_typecasters(connection): - if connection.encoding != 'UTF8': + if connection.encoding not in ('UTF8', 'SQLASCII', 'SQL_ASCII'): # In python3 when database encoding is other than utf-8 and client # encoding is set to UNICODE then we need to map data from database # encoding to utf-8.