Something that certainly should work, but does not, is to declare the type as a ClassVar[], since we scan these also in declarative:
class AlertItem2(Base):
__tablename__ = "alert_items2"
id = Column(BigInteger, primary_key=True, autoincrement=True)
signature = Column(String)
data_source_model_id = Column(Integer)
_only_unique_unresolved_alerts: ClassVar[Any] = data_source_model_id == None
__table_args__ = (
Index(
"_uq",
signature,
postgresql_where=_only_unique_unresolved_alerts,
unique=True,
),
)
we can add an issue for that use case and also augment the warning with this approach.
Originally posted by @zzzeek in #9826 (reply in thread)
Something that certainly should work, but does not, is to declare the type as a
ClassVar[], since we scan these also in declarative:we can add an issue for that use case and also augment the warning with this approach.
Originally posted by @zzzeek in #9826 (reply in thread)