Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup sqlalchemy warnings #24403

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions superset/connectors/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def is_virtual(self) -> bool:
def slices(self) -> RelationshipProperty:
return relationship(
"Slice",
overlaps="table",
primaryjoin=lambda: and_(
foreign(Slice.datasource_id) == self.id,
foreign(Slice.datasource_type) == self.type,
Expand Down
5 changes: 4 additions & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions superset/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down
2 changes: 2 additions & 0 deletions superset/models/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ 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')",
)
table = relationship(
"SqlaTable",
foreign_keys=[datasource_id],
overlaps="table",
primaryjoin="and_(Slice.datasource_id == SqlaTable.id, "
"Slice.datasource_type == 'table')",
remote_side="SqlaTable.id",
Expand Down
1 change: 1 addition & 0 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')",
Expand Down
6 changes: 5 additions & 1 deletion superset/tags/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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:
Expand Down