4 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Error with primaryjo...
FromSent OnAttachments
Jonathan Gardner28 Dec 2007 21:46 
Jonathan Gardner29 Dec 2007 09:53 
Michael Bayer29 Dec 2007 09:55 
Jonathan Gardner29 Dec 2007 12:08 
Subject:[sqlalchemy] Re: Error with primaryjoin in relation() in 0.4.1
From:Michael Bayer (mike@zzzcomputing.com)
Date:12/29/2007 09:55:52 AM
List:com.googlegroups.sqlalchemy

On Dec 29, 2007, at 12:46 AM, Jonathan Gardner wrote:

I'm getting a strange error when I specify primaryjoin in relation().

the error is because of the allow_column_override, combined with the fact that you haven't reassigned the column attributes for "left" and "right". the "left" and "right" columns on table2 need to be available as scalar attributes on your Table2 class since thats how foreign key attributes are tracked.

so get rid of the "allow_column_override" (any error message that says "specify X to ignore this condition" is pretty much a red flag) and set up the foreign key columns as something:

mapper(Table2, table2, properties={ '_left':table2.c.left, '_right':table2.c.right, 'left':relation(Table1, primaryjoin=table1.c.id==table2.c.left), 'right':relation(Table1, primaryjoin=table1.c.id==table2.c.right),

})