Hi Again

I was able to track down the issue. If the addresses attribute is  
replaced with a newly generated list containing all the items from  
the old list sqlalchemy apparently thinks that the elements are to be  
deleted (because the list was replaced) and marks them as orphan.

Same example like before with the code which puzzles sqlalchemy  
(http://www.sqlalchemy.org/docs/ 
datamapping.html#datamapping_relations_onetomany)

[...]
del u.addresses[1]
u.addresses.append(Address('27 New Place', 'Houston', 'TX', '34839'))

# BAD IDEA
lst=list()
for a in u.addresses:
        lst.append(a)

u.addresses=lst
# END OF BAD IDEA

session.flush()

==> BOOM



Am 28.06.2007 um 17:09 schrieb Michael Bayer:

>
>
> On Jun 28, 2007, at 9:16 AM, znerol wrote:
>
>>
>> Hi All
>>
>> Yes, i know, there is a FAQ-entry and i realized that this issue was
>> discussed before. Regretably i'm not able to make things work with a
>> one-to-many relationship using cascade="all, delete-orphan". Now i
>> discovered that even the example from the documentation raises this
>> exception (1). I'm using sqlalchemy 0.3.8 and python 2.4.3.
>>
>> 1) http://www.sqlalchemy.org/docs/
>> datamapping.html#datamapping_relations_onetomany
>
> its been fixed on the site.  if the mappers are being rebuilt, all
> sessions from the old mappers are invalid and must be cleared.
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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