diff --git a/redash/query_runner/mssql.py b/redash/query_runner/mssql.py index e8c544808d..40f52a7794 100644 --- a/redash/query_runner/mssql.py +++ b/redash/query_runner/mssql.py @@ -1,6 +1,7 @@ import json import logging import sys +import uuid from redash.query_runner import * from redash.utils import JSONEncoder @@ -22,6 +23,12 @@ 5: TYPE_FLOAT, } +class MSSQLJSONEncoder(JSONEncoder): + def default(self, o): + if isinstance(o, uuid.UUID): + return str(o) + return super(MSSQLJSONEncoder, self).default(o) + class SqlServer(BaseSQLQueryRunner): @classmethod def configuration_schema(cls): @@ -123,7 +130,7 @@ def run_query(self, query): rows = [dict(zip((c['name'] for c in columns), row)) for row in data] data = {'columns': columns, 'rows': rows} - json_data = json.dumps(data, cls=JSONEncoder) + json_data = json.dumps(data, cls=MSSQLJSONEncoder) error = None else: error = "No data was returned."