fix: dataset validate默认sql_query为空/缺少查询参数提示
This commit is contained in:
parent
e51d19fac0
commit
ad0c3cdd7c
|
@ -11,7 +11,7 @@ class DatasetCreateUpdateSerializer(CustomModelSerializer):
|
||||||
exclude = EXCLUDE_FIELDS
|
exclude = EXCLUDE_FIELDS
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
sql_query = attrs['sql_query']
|
sql_query = attrs.get('sql_query', '')
|
||||||
if sql_query:
|
if sql_query:
|
||||||
check_sql_safe(sql_query)
|
check_sql_safe(sql_query)
|
||||||
return attrs
|
return attrs
|
||||||
|
|
|
@ -70,6 +70,8 @@ class DatasetViewSet(CustomModelViewSet):
|
||||||
|
|
||||||
if dt.sql_query:
|
if dt.sql_query:
|
||||||
sql_f_ = check_sql_safe(dt.sql_query.format(**query))
|
sql_f_ = check_sql_safe(dt.sql_query.format(**query))
|
||||||
|
if '{' in sql_f_:
|
||||||
|
raise ParseError('未指定查询参数')
|
||||||
sql_f_l = sql_f_.strip(';').split(';')
|
sql_f_l = sql_f_.strip(';').split(';')
|
||||||
hash_k = hash(sql_f_.strip(';'))
|
hash_k = hash(sql_f_.strip(';'))
|
||||||
hash_v = cache.get(hash_k, None)
|
hash_v = cache.get(hash_k, None)
|
||||||
|
|
Loading…
Reference in New Issue