Fix json issues (#5865)

This commit is contained in:
Khushboo Vashi authored and GitHub committed 2023-02-16 10:46:39 +00:00
1 parent a0b8676f61
commit 5f52bb59dd
3 files changed
+10 -4

No files matched your search

@@ -374,7 +374,10 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
if k in ('description',):
data[k] = v
else:
data[k] = json.loads(v, cls=ColParamsJSONDecoder)
try:
data[k] = json.loads(v, cls=ColParamsJSONDecoder)
except TypeError:
data[k] = v
required_args = {
'name': 'Name',
+6 -1
View File
@@ -27,7 +27,12 @@ class DataTypeJSONEncoder(json.JSONEncoder):
if isinstance(obj, decimal.Decimal):
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):
@@ -1987,8 +1987,6 @@ Failed to reset the connection to the server due to following error:
if parameters:
mogrified_sql = cursor.mogrify(query, parameters)
if isinstance(mogrified_sql, bytes):
mogrified_sql = mogrified_sql.decode(self.python_encoding)
return mogrified_sql
else:
return query