__init__.py
branchstable
changeset 3634 a2d00ff6eb68
parent 3601 d77025be6f06
child 3651 633b8971c95a
equal deleted inserted replaced
3633:2d81178bea5f 3634:a2d00ff6eb68
   131         create_entity('Person', ('works_for', 'Y'), Y=c.eid, firstname='John', lastname='Doe')
   131         create_entity('Person', ('works_for', 'Y'), Y=c.eid, firstname='John', lastname='Doe')
   132 
   132 
   133         """
   133         """
   134         rql = 'INSERT %s X' % etype
   134         rql = 'INSERT %s X' % etype
   135         relations = []
   135         relations = []
   136         restrictions = []
   136         restrictions = set()
   137         cachekey = []
   137         cachekey = []
   138         for rtype, rvar in args:
   138         for rtype, rvar in args:
   139             relations.append('X %s %s' % (rtype, rvar))
   139             relations.append('X %s %s' % (rtype, rvar))
   140             restrictions.append('%s eid %%(%s)s' % (rvar, rvar))
   140             restriction = '%s eid %%(%s)s' % (rvar, rvar)
       
   141             if not restriction in restrictions:
       
   142                 restrictions.add(restriction)
   141             cachekey.append(rvar)
   143             cachekey.append(rvar)
   142         for attr in kwargs:
   144         for attr in kwargs:
   143             if attr in cachekey:
   145             if attr in cachekey:
   144                 continue
   146                 continue
   145             relations.append('X %s %%(%s)s' % (attr, attr))
   147             relations.append('X %s %%(%s)s' % (attr, attr))