You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2021/08/27 14:20:59 UTC

[superset] branch master updated: fix: create example DB if needed (#16451)

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

beto 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 62d8ab7  fix: create example DB if needed (#16451)
62d8ab7 is described below

commit 62d8ab7f9c044e2887de794484c30c2108213e0b
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Fri Aug 27 07:19:37 2021 -0700

    fix: create example DB if needed (#16451)
    
    * fix: create example DB if needed
    
    * fix lint
---
 superset/commands/importers/v1/examples.py | 6 ++----
 superset/models/slice.py                   | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/superset/commands/importers/v1/examples.py b/superset/commands/importers/v1/examples.py
index 66563f8..b743135 100644
--- a/superset/commands/importers/v1/examples.py
+++ b/superset/commands/importers/v1/examples.py
@@ -43,8 +43,8 @@ from superset.databases.schemas import ImportV1DatabaseSchema
 from superset.datasets.commands.importers.v1 import ImportDatasetsCommand
 from superset.datasets.commands.importers.v1.utils import import_dataset
 from superset.datasets.schemas import ImportV1DatasetSchema
-from superset.models.core import Database
 from superset.models.dashboard import dashboard_slices
+from superset.utils.core import get_example_database
 
 
 class ImportExamplesCommand(ImportModelsCommand):
@@ -104,9 +104,7 @@ class ImportExamplesCommand(ImportModelsCommand):
         # If database_uuid is not in the list of UUIDs it means that the examples
         # database was created before its UUID was frozen, so it has a random UUID.
         # We need to determine its ID so we can point the dataset to it.
-        examples_db = (
-            db.session.query(Database).filter_by(database_name="examples").first()
-        )
+        examples_db = get_example_database()
         dataset_info: Dict[str, Dict[str, Any]] = {}
         for file_name, config in configs.items():
             if file_name.startswith("datasets/"):
diff --git a/superset/models/slice.py b/superset/models/slice.py
index b4c7f66..9093cfa 100644
--- a/superset/models/slice.py
+++ b/superset/models/slice.py
@@ -53,7 +53,7 @@ slice_user = Table(
 logger = logging.getLogger(__name__)
 
 
-class Slice(  # pylint: disable=too-many-public-methods
+class Slice(  # pylint: disable=too-many-public-methods, too-many-instance-attributes
     Model, AuditMixinNullable, ImportExportMixin
 ):
     """A slice is essentially a report or a view on data"""