4 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Mapper bug involving...
FromSent OnAttachments
Brian Beck27 Oct 2007 17:33 
Michael Bayer27 Oct 2007 21:52 
Brian Beck28 Oct 2007 13:32 
Michael Bayer28 Oct 2007 14:38 
Subject:[sqlalchemy] Re: Mapper bug involving select with labeled foreign key target and clause default?
From:Michael Bayer (mike@zzzcomputing.com)
Date:10/28/2007 02:38:28 PM
List:com.googlegroups.sqlalchemy

On Oct 28, 2007, at 4:32 PM, Brian Beck wrote:

Pretend the Select is more complicated and needs to reference both IDs (which may have come from subqueries) -- in this case any mapper features (like synonym) don't help, the Select needs to exist first!

the select can reference whatever columns it wishes in its WHERE clause, ORDER BY clause, whereever, *without* them being in the columns clause...your columns clause need not reference any columns whatsoever and it can still locate the correct rows. so you should be putting only unique columns in the columns clause of your SELECT. or, if youd like to tell your mapper about both columns being the same, set up the mapping like this:

ab_mapper = mapper(AB, s, properties={ 'id':[s.c.a_id, s.c.the_id_of_a] })

then the class has a single 'id' attribute mapped to both columns.

Isn't it an error that b_id trips off a refresh? The correct values are inserted and should be available in last_inserted_ids for the mapper to populate instance with...

this is a slight issue in that its seeing the inline SQL as a postfetch trigger when its not, so that is fixed in r3679.