[dataimport] make it possible to insert 'empty' (i.e. no-attrs) entities stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 14 Feb 2011 16:46:49 +0100
branchstable
changeset 6989 4a999a647f52
parent 6987 d62d4ba5ef3e
child 6990 353ad06867a8
[dataimport] make it possible to insert 'empty' (i.e. no-attrs) entities In such cases (e.g. ternary relations), generated RQL must be 'INSERT MyEntityType' instead of 'INSERT MyEntityType:'
dataimport.py
--- a/dataimport.py	Mon Feb 14 09:37:17 2011 +0100
+++ b/dataimport.py	Mon Feb 14 16:46:49 2011 +0100
@@ -453,8 +453,10 @@
         return entity
 
     def _put(self, type, item):
-        query = ('INSERT %s X: ' % type) + ', '.join('X %s %%(%s)s' % (k, k)
-                                                     for k in item)
+        query = 'INSERT %s X' % type
+        if item:
+            query += ': ' + ', '.join('X %s %%(%s)s' % (k, k)
+                                      for k in item)
         return self.rql(query, item)[0][0]
 
     def relate(self, eid_from, rtype, eid_to, inlined=False):