cubicweb/dataimport/pgstore.py
changeset 11129 97095348b3ee
parent 11091 29aebc1edd29
parent 11057 0b59724cb3f2
child 11140 fabcd1c6dcd1
equal deleted inserted replaced
11128:9b4de34ad394 11129:97095348b3ee
    28 
    28 
    29 from six import string_types, integer_types, text_type, binary_type
    29 from six import string_types, integer_types, text_type, binary_type
    30 from six.moves import cPickle as pickle, range
    30 from six.moves import cPickle as pickle, range
    31 
    31 
    32 from cubicweb.utils import make_uid
    32 from cubicweb.utils import make_uid
    33 from cubicweb.server.utils import eschema_eid
       
    34 from cubicweb.server.sqlutils import SQL_PREFIX
    33 from cubicweb.server.sqlutils import SQL_PREFIX
    35 from cubicweb.dataimport.stores import NoHookRQLObjectStore
    34 from cubicweb.dataimport.stores import NoHookRQLObjectStore
    36 
    35 
    37 
    36 
    38 def _execmany_thread_not_copy_from(cu, statement, data, table=None,
    37 def _execmany_thread_not_copy_from(cu, statement, data, table=None,
   423             extid = b64encode(extid).decode('ascii')
   422             extid = b64encode(extid).decode('ascii')
   424         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid,
   423         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid,
   425                  'asource': source.uri}
   424                  'asource': source.uri}
   426         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   425         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   427         # insert core relations: is, is_instance_of and cw_source
   426         # insert core relations: is, is_instance_of and cw_source
   428         try:
   427         self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',
   429             self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',
   428                                      (entity.eid, entity.e_schema.eid))
   430                                          (entity.eid, eschema_eid(cnx, entity.e_schema)))
   429         for eschema in entity.e_schema.ancestors() + [entity.e_schema]:
   431         except IndexError:
   430             self._handle_is_relation_sql(cnx,
   432             # during schema serialization, skip
   431                                          'INSERT INTO is_instance_of_relation(eid_from,eid_to) VALUES (%s,%s)',
   433             pass
   432                                          (entity.eid, eschema.eid))
   434         else:
   433         self._handle_is_relation_sql(cnx, 'INSERT INTO cw_source_relation(eid_from,eid_to) VALUES (%s,%s)',
   435             for eschema in entity.e_schema.ancestors() + [entity.e_schema]:
   434                                      (entity.eid, source.eid))
   436                 self._handle_is_relation_sql(cnx,
       
   437                                              'INSERT INTO is_instance_of_relation(eid_from,eid_to) VALUES (%s,%s)',
       
   438                                              (entity.eid, eschema_eid(cnx, eschema)))
       
   439         if 'CWSource' in self.schema and source.eid is not None: # else, cw < 3.10
       
   440             self._handle_is_relation_sql(cnx, 'INSERT INTO cw_source_relation(eid_from,eid_to) VALUES (%s,%s)',
       
   441                                          (entity.eid, source.eid))
       
   442         # now we can update the full text index
   435         # now we can update the full text index
   443         if self.do_fti and self.need_fti_indexation(entity.cw_etype):
   436         if self.do_fti and self.need_fti_indexation(entity.cw_etype):
   444             self.index_entity(cnx, entity=entity)
   437             self.index_entity(cnx, entity=entity)