diff --git a/apps/bi/views.py b/apps/bi/views.py index f9678556..aafee7f6 100644 --- a/apps/bi/views.py +++ b/apps/bi/views.py @@ -69,9 +69,10 @@ class DatasetViewSet(CustomModelViewSet): can_cache = True if dt.sql_query: - sql_f_ = check_sql_safe(dt.sql_query.format(**query)) - if '{' in sql_f_: - raise ParseError('未指定查询参数') + try: + sql_f_ = check_sql_safe(dt.sql_query.format(**query)) + except KeyError: + raise ParseError('需指定查询参数') sql_f_l = sql_f_.strip(';').split(';') hash_k = hash(sql_f_.strip(';')) hash_v = cache.get(hash_k, None)