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]

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to