Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for serialising UUID type within MSSQL #961 #1089

Merged
merged 1 commit into from
Jun 1, 2016
Merged
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
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