On Jan 23, 2008, at 8:01 AM, maxi wrote:

>
> I create an instance of Convenio [ convenio = Convenio() ]
> I do, convenio.prestaciones.delete(obj_instance) for delete a object
> from "prestaciones" list.
> Now, if I delete one object only, this work fine, but if I delete many
> (i.e: two obj) that error ocurr when I call to
> session.flush([convenio]).
>

the error is specifically about a many to many table where it expects  
to delete two rows but only one matches the criteria.  If you are  
using more than one session, or removing rows from a many to many  
table using SQL statements, this error can occur.

Another condition, also mentioned in the original thread, that can  
exactly cause this issue is if you set up two many-to-many relations  
against the same table, instead of using a backref, like:

mapper(A, a, properties={
    'bs':relation(B, secondary=a_to_b)
})

mapper(B, b, properties={
    'as':relation(A, secondary=a_to_b)
})

The correct way to do the above is:

mapper(A, a, properties={
    'bs':relation(B, secondary=a_to_b, backref='bs')
})

mapper(B, b)

hope this helps....

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