Sorry, I didn't clarify, I was speaking about with 0.3, not with 0.4.

On Dec 14, 11:25 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Dec 14, 2007, at 1:34 PM, dykang wrote:
>
>
>
>
>
> > This example can't work in this sequence, or this query can't be run
> > and mapped?
> > If I wanted to execute this query:
> > SELECT inner_query.test_id AS inner_query_test_id,
> > inner_query.test_other_id AS inner_query_test_other_id,
> > inner_query.test_active AS inner_query_test_active,
> > inner_query.test2_id AS inner_query_test2_id,
> > inner_query.test2_other_id AS inner_query_test2_other_id,
> > inner_query.test2_active AS inner_query_test2_active
> > FROM (SELECT test.id AS test_id, test.other_id AS test_other_id,
> > test.active AS test_active, test2.id AS test2_id, test2.other_id AS
> > test2_other_id, test2.active AS test2_active
> > FROM test JOIN test2 ON test2.other_id = test.id) AS inner_query
>
> > is my only option to do this query through text and build out my own
> >column_labelsdictionary?
>
> im not seeing how you have that impression?  the constructed "s2"
> query in your example produces that exact SQL.   as I said, you only
> need to inform the Query about the "s2" alias, using the
> contains_alias() option for the primary mapper and add_entity() for
> additional mappers, so that it can translate incoming columns for the
> mappers.
>
> print
> session
> .query
> (Test
> ).options
> (contains_alias(s2)).add_entity(Test2,alias=s2).instances(s2.execute())
> print
> session
> .query
> (Test
> ).from_statement
> (s2).options(contains_alias(s2)).add_entity(Test2,alias=s2).all()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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