chore: cleanup sqlalchemy warnings (#24403)

This commit is contained in:
Maxime Beauchemin 2023-06-16 15:30:47 -07:00 committed by GitHub
parent b68de27dc6
commit b70808d071
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 2 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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, "

View File

@ -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",

View File

@ -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')",

View File

@ -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: