# HG changeset patch # User Sylvain Thénault # Date 1281109026 -7200 # Node ID f2580c7abc266d2b8eaaf4fae37de587dc13d0db # Parent bf684f1022bfd8ca5050325fcb49fd19906976d1 [migration] fix rename_entity_type bug: not putting eids of relation deleted using sql query may cause later error on commit, complaining on missing relation on an entity which has been actually deleted diff -r bf684f1022bf -r f2580c7abc26 server/migractions.py --- a/server/migractions.py Fri Aug 06 17:35:02 2010 +0200 +++ b/server/migractions.py Fri Aug 06 17:37:06 2010 +0200 @@ -876,7 +876,15 @@ self.sqlexec('UPDATE %s_relation SET eid_to=%s WHERE eid_to=%s' % (rtype, new.eid, oldeid), ask_confirm=False) # delete relations using SQL to avoid relations content removal - # triggered by schema synchronization hooks + # triggered by schema synchronization hooks. Should add deleted eids + # into pending eids else we may get some validation error on commit + # since integrity hooks may think some required relation is + # missing... + pending = self.session.transaction_data.setdefault('pendingeids', set()) + for eid, in self.sqlexec('SELECT cw_eid FROM cw_CWRelation ' + 'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s', + {'eid': oldeid}, ask_confirm=False): + pending.add(eid) self.sqlexec('DELETE FROM cw_CWRelation ' 'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s', {'eid': oldeid}, ask_confirm=False)