On Aug 9, 2010, at 10:56 AM, Nikolaj wrote: > I have an association object pattern between Person and Item through > PersonItem. Item is subclassed using single-table inheritance into > FooItem and BarItem, with a column named 'foo' on FooItem (although > it's obviously on the same shared table as BarItem). > > I'd like to query PersonItem and joinedload(Person.item) with > polymorphic columns. However, I end up resorting to the pattern on the > last line below because I can't figure out how to add columns to the > SELECT without having them appear in the result entities. Is there a > way to accomplish this more easily? > > results = Session.query(PersonItem) \ > .options( > joinedload(PersonItem.person, innerjoin=True), > joinedload(PersonItem.item, innerjoin=True) > ) \ > .add_columns(Item.__table__.c.foo) \ > .all() > > if results: results = zip(*results)[0]
the proposed syntax for this is joinedload(PersonItem.item.of_type(FooItem, BarItem)), but that is not implemented at the moment. The usual of_type() accessor only supports one subclass at the moment, and it is not implemented for loader options. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.