You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2023/06/16 22:30:53 UTC

[superset] branch master updated: chore: cleanup sqlalchemy warnings (#24403)

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

maximebeauchemin 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 b70808d071 chore: cleanup sqlalchemy warnings (#24403)
b70808d071 is described below

commit b70808d071517d1c1ad3b5ed879754f0455dd0be
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Fri Jun 16 15:30:47 2023 -0700

    chore: cleanup sqlalchemy warnings (#24403)
---
 superset/connectors/base/models.py | 1 +
 superset/connectors/sqla/models.py | 5 ++++-
 superset/models/dashboard.py       | 1 +
 superset/models/slice.py           | 2 ++
 superset/models/sql_lab.py         | 1 +
 superset/tags/models.py            | 6 +++++-
 6 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py
index d43d078639..f370a9f64c 100644
--- a/superset/connectors/base/models.py
+++ b/superset/connectors/base/models.py
@@ -152,6 +152,7 @@ class BaseDatasource(
     def slices(self) -> RelationshipProperty:
         return relationship(
             "Slice",
+            overlaps="table",
             primaryjoin=lambda: and_(
                 foreign(Slice.datasource_id) == self.id,
                 foreign(Slice.datasource_type) == self.type,
diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index fd3e9bb71a..ad3ba6f19b 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -1611,6 +1611,9 @@ class RowLevelSecurityFilter(Model, AuditMixinNullable):
         backref="row_level_security_filters",
     )
     tables = relationship(
-        SqlaTable, secondary=RLSFilterTables, backref="row_level_security_filters"
+        SqlaTable,
+        overlaps="table",
+        secondary=RLSFilterTables,
+        backref="row_level_security_filters",
     )
     clause = Column(Text, nullable=False)
diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index 3adffd122d..a23e25a1ab 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -149,6 +149,7 @@ class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
     owners = relationship(security_manager.user_model, secondary=dashboard_user)
     tags = relationship(
         "Tag",
+        overlaps="objects,tag,tags,tags",
         secondary="tagged_object",
         primaryjoin="and_(Dashboard.id == TaggedObject.object_id)",
         secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
diff --git a/superset/models/slice.py b/superset/models/slice.py
index eb48cc148a..fc8174878a 100644
--- a/superset/models/slice.py
+++ b/superset/models/slice.py
@@ -99,6 +99,7 @@ class Slice(  # pylint: disable=too-many-public-methods
     tags = relationship(
         "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')",
@@ -106,6 +107,7 @@ class Slice(  # pylint: disable=too-many-public-methods
     table = relationship(
         "SqlaTable",
         foreign_keys=[datasource_id],
+        overlaps="table",
         primaryjoin="and_(Slice.datasource_id == SqlaTable.id, "
         "Slice.datasource_type == 'table')",
         remote_side="SqlaTable.id",
diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py
index aeb4ba39df..fbadaaa2f4 100644
--- a/superset/models/sql_lab.py
+++ b/superset/models/sql_lab.py
@@ -383,6 +383,7 @@ class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
     tags = relationship(
         "Tag",
         secondary="tagged_object",
+        overlaps="tags",
         primaryjoin="and_(SavedQuery.id == TaggedObject.object_id)",
         secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
         "TaggedObject.object_type == 'query')",
diff --git a/superset/tags/models.py b/superset/tags/models.py
index bb845303ff..d7feb4f48c 100644
--- a/superset/tags/models.py
+++ b/superset/tags/models.py
@@ -77,6 +77,10 @@ class Tag(Model, AuditMixinNullable):
     name = Column(String(250), unique=True)
     type = Column(Enum(TagTypes))
 
+    objects = relationship(
+        "TaggedObject", back_populates="tag", overlaps="objects,tags"
+    )
+
 
 class TaggedObject(Model, AuditMixinNullable):
 
@@ -93,7 +97,7 @@ class TaggedObject(Model, AuditMixinNullable):
     )
     object_type = Column(Enum(ObjectTypes))
 
-    tag = relationship("Tag", backref="objects")
+    tag = relationship("Tag", back_populates="objects", overlaps="tags")
 
 
 def get_tag(name: str, session: Session, type_: TagTypes) -> Tag: