You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/09/27 19:23:26 UTC

[superset] branch hugh/fix-unique created (now 1c7104e)

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

hugh pushed a change to branch hugh/fix-unique
in repository https://gitbox.apache.org/repos/asf/superset.git.


      at 1c7104e  add condition to make sure columns are available before throwing

This branch includes the following new commits:

     new 1c7104e  add condition to make sure columns are available before throwing

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[superset] 01/01: add condition to make sure columns are available before throwing

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hugh/fix-unique
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 1c7104ebc95d22abacf69952838911371fb39b04
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Sep 27 15:12:48 2021 -0400

    add condition to make sure columns are available before throwing
---
 superset/connectors/sqla/models.py |  4 +++-
 superset/datasets/dao.py           | 11 +++--------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 7cebb8b..dffa3f9 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -1673,7 +1673,9 @@ class SqlaTable(Model, BaseDatasource):  # pylint: disable=too-many-public-metho
 
         if not DatasetDAO.validate_uniqueness(
             target.database_id, target.schema, target.table_name
-        ):
+        ) and hasattr(
+            target, "columns"
+        ):  # skip if there aren't columns updated
             raise Exception(get_dataset_exist_error_msg(target.full_name))
 
     @staticmethod
diff --git a/superset/datasets/dao.py b/superset/datasets/dao.py
index 8aee37b..e507e72 100644
--- a/superset/datasets/dao.py
+++ b/superset/datasets/dao.py
@@ -153,23 +153,18 @@ class DatasetDAO(BaseDAO):  # pylint: disable=too-many-public-methods
         """
         Updates a Dataset model on the metadata DB
         """
+
         if "columns" in properties:
             properties["columns"] = cls.update_columns(
                 model, properties.get("columns", []), commit=commit
             )
+
         if "metrics" in properties:
             properties["metrics"] = cls.update_metrics(
                 model, properties.get("metrics", []), commit=commit
             )
 
-        if override_columns:
-            # remove columns initially for full refresh
-            original_properties = properties["columns"]
-            properties["columns"] = []
-            super().update(model, properties, commit=commit)
-            properties["columns"] = original_properties
-
-        return super().update(model, properties, commit=False)
+        return super().update(model, properties, commit=True)
 
     @classmethod
     def update_columns(