Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tgext/debugbar/sections/sqla.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def default(self, obj):
return str(obj)
else:
return json.JSONEncoder.default(self, obj)
json_encoder = ExtendedJSONEncoder()
json_encoder = lambda x: json.dumps(x, cls=ExtendedJSONEncoder)

import tg
from tg import config, request, app_globals
Expand Down Expand Up @@ -89,6 +89,9 @@ def title(self):
return _('SQLAlchemy')

def _gather_queries(self):
if "sqlalchemy.json_serializer" in config:
json_encoder = config["sqlalchemy.json_serializer"]

queries = getattr(request, 'tgdb_sqla_queries', [])
if not queries:
return []
Expand All @@ -98,7 +101,7 @@ def _gather_queries(self):
is_select = query['statement'].strip().lower().startswith('select')
params = ''
try:
params = json_encoder.encode(query['parameters'])
params = json_encoder(query['parameters'])
except TypeError:
return 'Unable to serialize parameters of the query'

Expand Down