Fix templating in sqla datasource (#4971)

Fix templating in sqla datasource [has migration]
This commit is contained in:
Ville Brofeldt
2018-05-10 20:28:56 +03:00
committed by Maxime Beauchemin
parent 94249ed20c
commit af4dd59661
7 changed files with 52 additions and 9 deletions

View File

@@ -25,6 +25,15 @@ from superset import security_manager
from superset.utils import QueryStatus
def json_to_dict(json_str):
if json_str:
val = re.sub(',[ \t\r\n]+}', '}', json_str)
val = re.sub(',[ \t\r\n]+\]', ']', val)
return json.loads(val)
else:
return {}
class ImportMixin(object):
export_parent = None
# The name of the attribute
@@ -216,12 +225,11 @@ class ImportMixin(object):
@property
def params_dict(self):
if self.params:
params = re.sub(',[ \t\r\n]+}', '}', self.params)
params = re.sub(',[ \t\r\n]+\]', ']', params)
return json.loads(params)
else:
return {}
return json_to_dict(self.params)
@property
def template_params_dict(self):
return json_to_dict(self.template_params)
class AuditMixinNullable(AuditMixin):