> 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.
Sorry, I'am a little confuse abut it. (I have only one session) I've the next table schema: convenio(conv_id) <--- conv_pre(conv_pre_id, conv_id, pre_id) ---> prestacion(pre_id) (convenio many to many with prestacion across conv_pre) conv_pre has a unique index on (conv_id, pre_id) but conv_pre_id is the primary key Then, for simplify, I've this mapper: mapper(Convenio, convenio, properties={ 'prestaciones': relation(Prestacion, secondary=convenio_prestacion, lazy=True) } ) Now, I want to do: pre = session.query(Prestacion).get(123) conv = session.query(Convenio).get(1) conv.prestaciones.delete(pre) And this, must delete one record from conv_pre table where conv_id = 1 and pre_id = 123 (pre.pre_id) I don't understand why this error ocurr. You can explain me, please? Thanks so much for your help. > > 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 -~----------~----~----~----~------~----~------~--~---