Hi All,
I wish to do an aliased join similar to the last example in the
section http://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_joins
>>> session.query(User).\
... join('addresses',
aliased=True).filter(Address.email_address=='[EMAIL PROTECTED]').\
... join('addresses',
aliased=True).filter(Address.email_address=='[EMAIL PROTECTED]')
Except that I want to provide my own Alias for the Address table so I
can compare fields from the two aliased address tables, e.g.
>>> Address_1 = Address.table.alias()
>>> Address_2 = Address.table.alias()
>>> session.query(User).\
... join(Address_1).\
... join(Address_2).\
... filter(Address_1.email_address>Address_2.email_address)
This fails because the 'join' function above expects a property to
join on, rather than a table or table alias.
I've tried to transform it into a select_from query:
>>> User.query.select_from(User.table.join(Address_1).join(Address_2))./
... filter(Address_1.email_address>Address_2.email_address)
but then you lose the ability to add_entities; the following doesn't
work:
>>> User.query.add_entity(Address_1).select_from(User.table.join(Address_1).join(Address_2))./
... filter(Address_1.email_address>Address_2.email_address)
Any ideas on how to do this correctly?
Thanks,
Eoghan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---