You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2024/02/01 15:12:37 UTC

(superset) branch master updated: fix: Allow exporting saved queries without schema information (#26889)

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 4c5176eea8 fix: Allow exporting saved queries without schema information (#26889)
4c5176eea8 is described below

commit 4c5176eea82e3b168c5d11f130387d5913b33efa
Author: Sebastian Bernauer <se...@stackable.de>
AuthorDate: Thu Feb 1 16:12:29 2024 +0100

    fix: Allow exporting saved queries without schema information (#26889)
---
 superset/commands/query/export.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/superset/commands/query/export.py b/superset/commands/query/export.py
index a8fa8acbf0..43a110c3b9 100644
--- a/superset/commands/query/export.py
+++ b/superset/commands/query/export.py
@@ -40,11 +40,16 @@ class ExportSavedQueriesCommand(ExportModelsCommand):
     def _export(
         model: SavedQuery, export_related: bool = True
     ) -> Iterator[tuple[str, str]]:
-        # build filename based on database, optional schema, and label
+        # build filename based on database, optional schema, and label.
+        # we call secure_filename() multiple times and join the directories afterwards,
+        # as secure_filename() replaces "/" with "_".
         database_slug = secure_filename(model.database.database_name)
-        schema_slug = secure_filename(model.schema)
         query_slug = secure_filename(model.label) or str(model.uuid)
-        file_name = f"queries/{database_slug}/{schema_slug}/{query_slug}.yaml"
+        if model.schema is None:
+            file_name = f"queries/{database_slug}/{query_slug}.yaml"
+        else:
+            schema_slug = secure_filename(model.schema)
+            file_name = f"queries/{database_slug}/{schema_slug}/{query_slug}.yaml"
 
         payload = model.export_to_dict(
             recursive=False,