I'm (have to) working with sqlalchemy version 0.7,

because of that I can't use .select_entity_from().


But I have an other solution.


existing_query = session.query(TableOne).subquery()
TableOneAlias = aliased(TableOne, existing_query)

additional_query = session.query(TableTwo).subquery()
TableTwoAlias = aliased(TableTwo, additional_query)

combined_query = session.query(existing_query).join(additional_query)

q = combined_query.with_entities(TableOneAlias, TableTwoAlias)
print q
print q.all()


With this query I get the right object types as result.



Is there an other way to do this without calling aliased(...) explicitly?

For example extracting the aliased tables directly from the subquery?




Thank you for the tip with the query.column_descriptions.

It helped a lot.



-- 
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/groups/opt_out.

Reply via email to