Thanks. The name addition seems tidier to me so I switched to that for the moment.
On a somewhat unrelated note, I love the "what's new in 1.0" docs you linked. I had not checked them out yet. The "Performance" section is particularly awesome and well written. Aspects of it bring me back to putting together my profiling talk [1] from a while ago (optimizing SQLAlchemy inserts was a perfect vehicle for the talk). I'll have to update that thing now with the fancy new bulk operations... they look quite convenient for decent gain with little pain. Nice! Russ [1]: https://speakerdeck.com/rwarren/a-brief-intro-to-profiling-in-python On Monday, February 2, 2015 at 7:55:03 PM UTC-5, Michael Bayer wrote: > > > Russ <russand...@gmail.com <javascript:>> wrote: > > > I should have also indicated that the addition of sqlalchemy.sql.text > fixes the small mixin example. The little script below works, but I don't > know if it is a sketchy hack, or a safe long term solution: > > > > from sqlalchemy import * > > from sqlalchemy.orm import * > > from sqlalchemy.ext.declarative import declarative_base, declared_attr > > from sqlalchemy.sql import text as sql_text > > > > Base = declarative_base() > > > > class A_TableDef(object): > > __tablename__ = 'a' > > > > id = Column(Integer, primary_key=True) > > track_type = Column(SmallInteger, nullable = False) > > > > @declared_attr > > def __table_args__(cls): > > return (Index("idx_track_type2", "track_type", > > postgresql_where = sql_text("track_type != 0")), > > ) > > > > class A_Model(Base, A_TableDef): > > pass > > > > e = > create_engine("postgresql://postgres:postgrespw@localhost:5433/edms", echo > =True) > > > > Base.metadata.drop_all(e) > > Base.metadata.create_all(e) > > > with mixins, this will work as is in latest master, see > > http://docs.sqlalchemy.org/en/latest/changelog/migration_10.html#improvements-to-declarative-mixins-declared-attr-and-related-features. > > > > In 0.9, the declared_attr here is called sooner than we’d like, though > this > particular example works if we just give the column a name (more complex > things will still not work very well with the mixins here though): > > class A_TableDef(object): > __tablename__ = 'a' > id = Column(Integer, primary_key=True) > > track_type = Column('track_type', SmallInteger, nullable = False) > > @declared_attr > def __table_args__(cls): > return (Index("idx_track_type", "track_type", > postgresql_where=(cls.track_type != 0)), > ) > > The version with text() is perfectly fine as postgresql_where isn’t > significant anywhere except in the DDL. > > > > > > > > > -- > > 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+...@googlegroups.com <javascript:>. > > To post to this group, send email to sqlal...@googlegroups.com > <javascript:>. > > Visit this group at http://groups.google.com/group/sqlalchemy. > > For more options, visit https://groups.google.com/d/optout. > -- 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.