Fix json issues (#5865)

pull/5876/head
Khushboo Vashi 2023-02-16 16:16:39 +05:30 committed by GitHub
parent a0b8676f61
commit 5f52bb59dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -374,7 +374,10 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
if k in ('description',): if k in ('description',):
data[k] = v data[k] = v
else: else:
try:
data[k] = json.loads(v, cls=ColParamsJSONDecoder) data[k] = json.loads(v, cls=ColParamsJSONDecoder)
except TypeError:
data[k] = v
required_args = { required_args = {
'name': 'Name', 'name': 'Name',

View File

@ -27,7 +27,12 @@ class DataTypeJSONEncoder(json.JSONEncoder):
if isinstance(obj, decimal.Decimal): if isinstance(obj, decimal.Decimal):
return float(obj) return float(obj)
return json.JSONEncoder.default(self, obj) try:
retval = json.JSONEncoder.default(self, obj)
except TypeError:
retval = obj
return retval
class ColParamsJSONDecoder(json.JSONDecoder): class ColParamsJSONDecoder(json.JSONDecoder):

View File

@ -1987,8 +1987,6 @@ Failed to reset the connection to the server due to following error:
if parameters: if parameters:
mogrified_sql = cursor.mogrify(query, parameters) mogrified_sql = cursor.mogrify(query, parameters)
if isinstance(mogrified_sql, bytes):
mogrified_sql = mogrified_sql.decode(self.python_encoding)
return mogrified_sql return mogrified_sql
else: else:
return query return query