On Oct 27, 2007, at 8:33 PM, Brian Beck wrote:

>
> Sorry for the confusing subject.  If I map against a select in which
> one of the tables has a foreign key whose default value is set to a
> clause involving another table's column (also in the select), and that
> column is labeled, the correct values are inserted, but an exception
> is raised when accessing the foreign key attribute on the instance
> (the instance is in an invalid state).

without trying it yet the first thing that seems wrong is that your  
select has no join condition between a_table and b_table (nor are you  
using a join(), which would figure it out for you based on foreign  
keys, so your foreign key doesn't impact the equation much here on  
the select side).  the select will return the cartesian product  
between a and b which is definitely not what you want.

the actual error seems that the b_id column is tripping off a refresh  
of the instance's row, but when it issues your select(), its still  
not getting back what it wants.  since the mapper seems confused by  
the primary key of the select (which is likely because you have a_id  
represented twice), you might want to look into setting up your  
'the_id_of_a' property at the mapper level as a synonym() or  
column_property() attribute. I dont see what good it does embedded  
into that select().  or, try explicitly setting the mapper's  
primary_key attribute to the desired columns from your select().

just some things to try. 

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to