I am getting stuck trying to upgrade to 0.8.x, as I can't get correlation to work with nested subquery in column property. Here's a slightly absurd example for illustration:
from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Phone(Base): __tablename__ = 'phones' id = Column(Integer, primary_key=True) number = Column(String(20)) contact_id = Column(Integer, ForeignKey('contacts.id')) contact = relationship('Contact', backref='phones') class Contact(Base): __tablename__ = 'contacts' id = Column(Integer, primary_key=True) name = Column(String(200)) t = select( [Phone.number.label('value')], Phone.contact_id == Contact.id, ).correlate(Contact.__table__).alias('t') Contact.phone_numbers = column_property( select( [func.string_agg(t.c.value, ', ')], ).as_scalar().label('phone_numbers'), deferred=True, ) session = Session() print session.query(Contact).order_by(Contact.phone_numbers) """ 0.7.x: SELECT contacts.id AS contacts_id, contacts.name AS contacts_name FROM contacts ORDER BY (SELECT string_agg(t.value, :string_agg_2) AS string_agg_1 FROM (SELECT phones.number AS value FROM phones WHERE phones.contact_id = contacts.id) AS t) 0.8.x: SELECT contacts.id AS contacts_id, contacts.name AS contacts_name FROM contacts ORDER BY (SELECT string_agg(t.value, :string_agg_2) AS string_agg_1 FROM (SELECT phones.number AS value FROM phones, contacts WHERE phones.contact_id = contacts.id) AS t) """ I tried `correlate_except` but it doesn't work in this case either. Perhaps a side effect from ticket:2668? -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.