Hi Michael,

Thank you very much for your help and quick response.

The workaround worked.

I really like the simplicity of the query api that i automate the 
generation of it.
I will try to incorporate the workaround.

Thanks again

On Thursday, April 25, 2013 7:31:49 AM UTC+10, Michael Bayer wrote:
>
> Here's a technique you should be able to use as a workaround:
>
> 1. for every mapper that you're joining *to* which is also a joined 
> inheritance subclass, transform it into an aliased() construct
> 2. any join involving an aliased() construct, construct the ON criterion 
> manually.
>
> These two techniques should bypass all the automation in query.join() 
> that's failing, such as:
>
>     from sqlalchemy.orm import aliased
>
>     up = aliased(UserPerson)
>     pa = aliased(PersonAddress)
>
>     session.query(User).\
>         outerjoin(up, up.ItemUserPerson_Id == User.Id).\
>         outerjoin(pa, pa.ItemPerson_Id == up.Id).\
>         outerjoin(pa.Emails).\
>         outerjoin(pa.Phones).\
>         first()
>
>
>
>
> On Apr 24, 2013, at 1:38 PM, Michael Bayer 
> <mik...@zzzcomputing.com<javascript:>> 
> wrote:
>
> oh.  this *fails in 0.7 also*.   I thought this was a regression.    Yeah, 
> this query is a little crazier than we've planned for, I can see the 
> general thing it's failing to do but will have to see what's involved to 
> get it going.   But not a regression is good news at least.
>
>
> On Apr 24, 2013, at 8:35 AM, gvv <gvve...@gmail.com <javascript:>> wrote:
>
> Hi All,
>
> using 7.10 but falls over also in 8.0.
>
> User has a One2One UserPerson.
> UserPerson inherits from Person.
> Person has a One2Many PersonAddress.
> PersonAddress inherits from Address.
> Address has a One2Many Phone and One2Many Email.
>
> The following query falls over with an (OperationalError) no such column: 
> Address.Id.
>  
> session.query(User, UserPerson, PersonAddress).filter(User.Id == 1).\
>         
> outerjoin(User.Personal,UserPerson.Addresses,PersonAddress.Phones,PersonAddress.Emails).first()
>
> What am I doing wrong ?
>
> Thanks in advance for your help.
>
>
> sqlalchemy.exc.OperationalError: (OperationalError) no such column: 
> Address.Id u'SELECT "User"."Id" AS "User_Id", anon_1."UserPerson_Id" AS 
> "anon_1_UserPerson_Id", anon_1."Person_Id" AS "anon_1_Person_Id", 
> anon_1."Person_PersonType" AS "anon_1_Person_PersonType", 
> anon_1."UserPerson_ItemUserPerson_Id" AS 
> "anon_1_UserPerson_ItemUserPerson_Id", anon_2."PersonAddress_Id" AS 
> "anon_2_PersonAddress_Id", anon_2."Address_Id" AS "anon_2_Address_Id", 
> anon_2."Address_AddressType" AS "anon_2_Address_AddressType", 
> anon_2."PersonAddress_ItemPerson_Id" AS 
> "anon_2_PersonAddress_ItemPerson_Id" \nFROM "User" LEFT OUTER JOIN (SELECT 
> "Person"."Id" AS "Person_Id", "Person"."PersonType" AS "Person_PersonType", 
> "UserPerson"."Id" AS "UserPerson_Id", "UserPerson"."ItemUserPerson_Id" AS 
> "UserPerson_ItemUserPerson_Id" \nFROM "Person" JOIN "UserPerson" ON 
> "UserPerson"."Id" = "Person"."Id") AS anon_1 ON 
> anon_1."UserPerson_ItemUserPerson_Id" = "User"."Id" LEFT OUTER JOIN (SELECT 
> "Address"."Id" AS "Address_Id", "Address"."AddressType" AS 
> "Address_AddressType", "PersonAddress"."Id" AS "PersonAddress_Id", 
> "PersonAddress"."ItemPerson_Id" AS "PersonAddress_ItemPerson_Id" \nFROM 
> "Address" JOIN "PersonAddress" ON "PersonAddress"."Id" = "Address"."Id") AS 
> anon_2 ON anon_1."Person_Id" = anon_2."PersonAddress_ItemPerson_Id" LEFT 
> OUTER JOIN "Phone" ON anon_2."Address_Id" = "Phone"."ItemPhone_Id" LEFT 
> OUTER JOIN "Email" ON "Address"."Id" = "Email"."ItemEmail_Id" \nWHERE 
> "User"."Id" = ?\n LIMIT ? OFFSET ?' (1, 1, 0)
>
>
>
> -- 
> 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+...@googlegroups.com <javascript:>.
> To post to this group, send email to sqlal...@googlegroups.com<javascript:>
> .
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
> <test.py><decl_enum.py>
>
>
>
> -- 
> 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+...@googlegroups.com <javascript:>.
> To post to this group, send email to sqlal...@googlegroups.com<javascript:>
> .
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to