Skip to content

Commit

Permalink
修改filter_db_list
Browse files Browse the repository at this point in the history
  • Loading branch information
feiazifeiazi committed Sep 19, 2024
1 parent 0ac8077 commit a1a3cd1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sql_api/api_instance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from rest_framework import views, generics, status, serializers
from rest_framework.response import Response
from drf_spectacular.utils import extend_schema

from sql.utils.sql_utils import filter_db_list
from .serializers import (
InstanceSerializer,
InstanceDetailSerializer,
Expand Down Expand Up @@ -193,6 +195,12 @@ def post(self, 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 a1a3cd1

Please sign in to comment.