What is the proper way to declare a postgresql partial index when using the @declared_attr decorator?
This form gives me "Cannot compile Column object until its 'name' is assigned": track_type = Column(SmallInteger, nullable = False) @declared_attr def __table_args__(cls): return (Index("idx_track_type", "track_type", postgresql_where = (cls.track_type != 0)), ) and this form gives me "AttributeError: 'str' object has no attribute '_compiler_dispatch'": track_type = Column(SmallInteger, nullable = False) @declared_attr def __table_args__(cls): return (Index("idx_track_type", "track_type", postgresql_where = "track_type != 0"), ) >From [this post][1] I learned about the use of sqlalchemy.sql.text, so this is now working for me: from sqlalchemy.sql import text as sql_text # <snip> @declared_attr def __table_args__(cls): return (Index("idx_track_type", "track_type", postgresql_where = sql_text("track_type != 0")), ) That post also indicated there may be a bug here, but that was almost 2 years ago. Is there a better way to do it now? More importantly, will the working code above continue to work in the future? [1]: http://goo.gl/Fmgynh -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.