Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request getredash#1089 from James226/master
Browse files Browse the repository at this point in the history
Add support for serialising UUID type within MSSQL getredash#961
  • Loading branch information
arikfr committed Jun 1, 2016
2 parents 3d069bc + c3fe350 commit 8e7d406
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion redash/query_runner/mssql.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import sys
import uuid

from redash.query_runner import *
from redash.utils import JSONEncoder
Expand All @@ -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):
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit 8e7d406

Please sign in to comment.