Another try to fix JSON issues.

This commit is contained in:
Khushboo Vashi
2023-02-20 11:21:32 +05:30
committed by GitHub
parent aeb4867bdf
commit b9cbf08b51
2 changed files with 4 additions and 1 deletions
+2 -1
View File
@@ -26,7 +26,8 @@ class DataTypeJSONEncoder(json.JSONEncoder):
return (datetime.datetime.min + obj).time().isoformat()
if isinstance(obj, decimal.Decimal):
return float(obj)
if isinstance(obj, bytes):
return obj.decode('utf-8')
try:
retval = json.JSONEncoder.default(self, obj)
except TypeError:
@@ -1987,6 +1987,8 @@ 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