Skip to content

Commit

Permalink
过滤数据库改为统一出口地方
Browse files Browse the repository at this point in the history
  • Loading branch information
feiazifeiazi committed Sep 19, 2024
1 parent 49d860f commit 0ac8077
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions sql/engines/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions sql/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0ac8077

Please sign in to comment.