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

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

commit c260cfbebf7530c17fab90cd0d72ad33bb34cc50
Author: Maxime Beauchemin <[email protected]>
AuthorDate: Wed May 29 13:10:24 2024 -0700

    fix: address tag-related deletion issues raised in #26654
    
    I wasn't able to reproduce the issues in #26654, but wanted to submit this 
diff here as something to try. I'm not likely to push this through but thought 
a PR would be a good way to suggest a fix and open centralize the discussion.
---
 superset/models/dashboard.py | 5 ++---
 superset/models/slice.py     | 5 ++---
 superset/models/sql_lab.py   | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index 6e6989bf9e..552db39464 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -152,9 +152,8 @@ class Dashboard(AuditMixinNullable, ImportExportMixin, 
Model):
         "Tag",
         overlaps="objects,tag,tags,tags",
         secondary="tagged_object",
-        primaryjoin="and_(Dashboard.id == TaggedObject.object_id)",
-        secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
-        "TaggedObject.object_type == 'dashboard')",
+        primaryjoin="and_(Dashboard.id == TaggedObject.object_id, 
TaggedObject.object_type == 'dashboard')",
+        secondaryjoin="and_(TaggedObject.tag_id == Tag.id)",
     )
     published = Column(Boolean, default=False)
     is_managed_externally = Column(Boolean, nullable=False, default=False)
diff --git a/superset/models/slice.py b/superset/models/slice.py
index bc89b5b7c4..8c7706b93f 100644
--- a/superset/models/slice.py
+++ b/superset/models/slice.py
@@ -104,9 +104,8 @@ class Slice(  # pylint: disable=too-many-public-methods
         "Tag",
         secondary="tagged_object",
         overlaps="objects,tag,tags",
-        primaryjoin="and_(Slice.id == TaggedObject.object_id)",
-        secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
-        "TaggedObject.object_type == 'chart')",
+        primaryjoin="and_(Slice.id == TaggedObject.object_id, 
TaggedObject.object_type == 'chart')",
+        secondaryjoin="and_(TaggedObject.tag_id == Tag.id)",
     )
     table = relationship(
         "SqlaTable",
diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py
index 3c26c6c12f..c5a02bceb4 100644
--- a/superset/models/sql_lab.py
+++ b/superset/models/sql_lab.py
@@ -416,9 +416,8 @@ class SavedQuery(
         "Tag",
         secondary="tagged_object",
         overlaps="tags",
-        primaryjoin="and_(SavedQuery.id == TaggedObject.object_id)",
-        secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
-        "TaggedObject.object_type == 'query')",
+        primaryjoin="and_(SavedQuery.id == TaggedObject.object_id, 
TaggedObject.object_type == 'query')",
+        secondaryjoin="and_(TaggedObject.tag_id == Tag.id)",
     )
 
     export_parent = "database"

Reply via email to