[undo] consistent is/is_instance_of processing stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 30 Mar 2010 11:17:21 +0200
branchstable
changeset 5074 bc481dab93d4
parent 5073 a9697325cffa
child 5075 a4b735e76c66
[undo] consistent is/is_instance_of processing
server/session.py
server/sources/native.py
--- a/server/session.py	Tue Mar 30 11:15:57 2010 +0200
+++ b/server/session.py	Tue Mar 30 11:17:21 2010 +0200
@@ -28,6 +28,11 @@
 
 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy()
 NO_UNDO_TYPES.add('CWCache')
+# is / is_instance_of are usually added by sql hooks except when using
+# dataimport.NoHookRQLObjectStore, and we don't want to record them
+# anyway in the later case
+NO_UNDO_TYPES.add('is')
+NO_UNDO_TYPES.add('is_instance_of')
 # XXX rememberme,forgotpwd,apycot,vcsfile
 
 def is_final(rqlst, variable, args):
--- a/server/sources/native.py	Tue Mar 30 11:15:57 2010 +0200
+++ b/server/sources/native.py	Tue Mar 30 11:17:21 2010 +0200
@@ -927,6 +927,13 @@
         action.changes['cw_eid'] = eid
         sql = self.sqlgen.insert(SQL_PREFIX + etype, action.changes)
         self.doexec(session, sql, action.changes)
+        # add explicitly is / is_instance_of whose deletion is not recorded for
+        # consistency with addition (done by sql in hooks)
+        self.doexec(session, 'INSERT INTO is_relation(eid_from, eid_to) '
+                    'VALUES(%s, %s)' % (eid, eschema_eid(session, eschema)))
+        for eschema in entity.e_schema.ancestors() + [entity.e_schema]:
+            self.doexec(session, 'INSERT INTO is_instance_of_relation(eid_from,'
+                        'eid_to) VALUES(%s, %s)' % (eid, eschema_eid(session, eschema)))
         # restore record in entities (will update fti if needed)
         self.add_info(session, entity, self, None, True)
         # remove record from deleted_entities if entity's type is multi-sources