On Mon, Apr 12, 2010 at 11:04 AM, Michael Bayer
<mike...@zzzcomputing.com> wrote:
> Anders Langworthy wrote:
>> Hi all,
>>
>> I've been trying to get the "grandchildren" relationship working in
>> the code below, but have just about run out of permutations to try.  I
>> couldn't get much out of the docs, and the archives turned up a few
>> similar queries but none with an answer.  Is this even possible?  Is
>> there a better way to accomplish this result (the collection of
>> related Grandchild objects accessible from an instance of Parent)?

> The error here regarding foreign keys is described here:
>
> http://www.sqlalchemy.org/trac/wiki/FAQ#ImusingDeclarativeandsettingprimaryjoinsecondaryjoinusinganand_oror_andIamgettinganerrormessageaboutforeignkeys.

Thank you Michael.  The relationship is now working (with a few other
additional parameters--see below).  I also sheepishly apologize for
posting a question apparently covered in the FAQ.

For the records here is an example of the working relationship.  The
names are different from those in my prior email but the nature of the
tables is the same (the table cases has a FK to clients which in turn
has a FK to users).  The relationship is declared on User:

    cases = relationship('Case', primaryjoin="and_(Case.clients_id==\
        Client.id,Client.users_id==User.id)",
        foreign_keys="[Case.clients_id,Client.users_id]", viewonly=True,
        remote_side="[Client.id]")

Cheers,
Anders.

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

Reply via email to