Skip to content

Commit

Permalink
fix(Database): Refresh catalogs on db update returns database error (#…
Browse files Browse the repository at this point in the history
…29681)

(cherry picked from commit 134ca38)
  • Loading branch information
geido authored and sadpandajoe committed Aug 12, 2024
1 parent de2eedd commit bca2366
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions superset/commands/database/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,36 +166,43 @@ def _refresh_catalogs(
)

for catalog in catalogs:
schemas = self._get_schema_names(database, catalog, ssh_tunnel)
try:
schemas = self._get_schema_names(database, catalog, ssh_tunnel)

if catalog:
perm = security_manager.get_catalog_perm(
original_database_name,
catalog,
)
existing_pvm = security_manager.find_permission_view_menu(
"catalog_access",
perm,
)
if not existing_pvm:
# new catalog
security_manager.add_permission_view_menu(
if catalog:
perm = security_manager.get_catalog_perm(
original_database_name,
catalog,
)
existing_pvm = security_manager.find_permission_view_menu(
"catalog_access",
security_manager.get_catalog_perm(
database.database_name,
catalog,
),
perm,
)
for schema in schemas:
if not existing_pvm:
# new catalog
security_manager.add_permission_view_menu(
"schema_access",
security_manager.get_schema_perm(
"catalog_access",
security_manager.get_catalog_perm(
database.database_name,
catalog,
schema,
),
)
for schema in schemas:
security_manager.add_permission_view_menu(
"schema_access",
security_manager.get_schema_perm(
database.database_name,
catalog,
schema,
),
)
continue
except DatabaseConnectionFailedError:
# more than one catalog, move to next
if catalog:
logger.warning("Error processing catalog %s", catalog)
continue
raise

# add possible new schemas in catalog
self._refresh_schemas(
Expand Down

0 comments on commit bca2366

Please sign in to comment.