cubicweb/server/sources/native.py
changeset 12731 8e5f2c449e60
parent 12614 8ac9ac8d9143
parent 12726 1a2c7d6397ec
child 12739 c6f8ca03718f
--- a/cubicweb/server/sources/native.py	Wed May 22 01:16:55 2019 +0200
+++ b/cubicweb/server/sources/native.py	Wed Oct 09 11:44:22 2019 +0200
@@ -648,6 +648,18 @@
     def delete_relation(self, cnx, subject, rtype, object):
         """delete a relation from the source"""
         rschema = self.schema.rschema(rtype)
+        # we should not issue UPDATE on inlined relations when subject is going
+        # to be deleted.
+        # Unless object is also going to be deleted and is not equal to the
+        # subject, in this case DELETE should occur in a order which cubicweb
+        # doesn't handle (yet). For example
+        # cubicweb/server/test/unittest_migractions.py::MigrationCommandsTC::test_add_drop_entity_type
+        # trigger such case.
+        if (
+            rschema.inlined and cnx.deleted_in_transaction(subject)
+            and (subject == object or not cnx.deleted_in_transaction(object))
+        ):
+            return
         self._delete_relation(cnx, subject, rtype, object, rschema.inlined)
         if cnx.ertype_supports_undo(rtype):
             self._record_tx_action(cnx, 'tx_relation_actions', u'R',