From 9d26946195c6f1f195cd94efcf99652b53d7c5c0 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 7 Jul 2023 15:36:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20bi=20exec=E6=9F=A5=E8=AF=A2=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/bi/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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)