From a800b19c87ce4f9a8567cac1a91988fbf4e2f955 Mon Sep 17 00:00:00 2001 From: Murtuza Zabuawala Date: Thu, 16 Jun 2016 11:20:00 +0100 Subject: [PATCH] Fix display of NaN and Bytea data. Fixes #1350. Fixes #1309 --- web/pgadmin/utils/driver/psycopg2/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index 794edeb07..500e9501e 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -37,6 +37,23 @@ _ = gettext ASYNC_WAIT_TIMEOUT = 0.01 # in seconds or 10 milliseconds +# This registers a unicode type caster for datatype 'RECORD'. +psycopg2.extensions.register_type( + psycopg2.extensions.new_type((2249,), "RECORD", + psycopg2.extensions.UNICODE) +) + +# Cast bytea fields to text. By default, this will render as hex strings with +# Postgres 9+ and as escaped binary in earlier versions. +psycopg2.extensions.register_type( + psycopg2.extensions.new_type((17,), 'BYTEA_TEXT', psycopg2.STRING) +) + +# This registers a type caster for datatype 'NaN'. +psycopg2.extensions.register_type( + psycopg2.extensions.new_type((701,), 'NaN_TEXT', psycopg2.STRING) +) + def register_date_typecasters(connection): """