From 0ac80779dabf128811b59aead08beab9ca463947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Thu, 19 Sep 2024 15:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=BB=9F=E4=B8=80=E5=87=BA=E5=8F=A3=E5=9C=B0?= =?UTF-8?q?=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/engines/mysql.py | 2 -- sql/instance.py | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sql/engines/mysql.py b/sql/engines/mysql.py index 3c71080a96..a25422fb09 100644 --- a/sql/engines/mysql.py +++ b/sql/engines/mysql.py @@ -198,8 +198,6 @@ def get_all_databases(self): db_list = [ row[0] for row in result.rows if row[0] not in self.forbidden_databases ] - db_list = filter_db_list(db_list, self.instance.show_db_name_regex, True) - db_list = filter_db_list(db_list, self.instance.denied_db_name_regex, False) result.rows = db_list return result diff --git a/sql/instance.py b/sql/instance.py index 54486be745..a9b9332e2e 100644 --- a/sql/instance.py +++ b/sql/instance.py @@ -14,6 +14,7 @@ from common.utils.convert import Convert from sql.engines import get_engine from sql.plugins.schemasync import SchemaSync +from sql.utils.sql_utils import filter_db_list from .models import Instance, ParamTemplate, ParamHistory @@ -332,6 +333,12 @@ def instance_resource(request): tb_name = query_engine.escape_string(tb_name) if resource_type == "database": resource = query_engine.get_all_databases() + resource = filter_db_list( + resource, query_engine.instance.show_db_name_regex, True + ) + resource = filter_db_list( + resource, query_engine.instance.denied_db_name_regex, False + ) elif resource_type == "schema" and db_name: resource = query_engine.get_all_schemas(db_name=db_name) elif resource_type == "table" and db_name: