cubicweb/server/sources/native.py
changeset 11773 054a947b5415
parent 11767 432f87a63057
child 11774 51c160677afe
equal deleted inserted replaced
11772:54fa73a2f931 11773:054a947b5415
   841         assert cnx.cnxset is not None
   841         assert cnx.cnxset is not None
   842         # begin by inserting eid/type/source/extid into the entities table
   842         # begin by inserting eid/type/source/extid into the entities table
   843         if extid is not None:
   843         if extid is not None:
   844             assert isinstance(extid, binary_type)
   844             assert isinstance(extid, binary_type)
   845             extid = b64encode(extid).decode('ascii')
   845             extid = b64encode(extid).decode('ascii')
   846         attrs = {'type': text_type(entity.cw_etype), 'eid': entity.eid, 'extid': extid,
   846         attrs = {'type': text_type(entity.cw_etype), 'eid': entity.eid, 'extid': extid}
   847                  'asource': text_type(source.uri)}
       
   848         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   847         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   849         # insert core relations: is, is_instance_of and cw_source
   848         # insert core relations: is, is_instance_of and cw_source
   850 
   849 
   851         if entity.e_schema.eid is not None:  # else schema has not yet been serialized
   850         if entity.e_schema.eid is not None:  # else schema has not yet been serialized
   852             self._handle_is_relation_sql(
   851             self._handle_is_relation_sql(
  1332         yield sql
  1331         yield sql
  1333     for sql in ("""
  1332     for sql in ("""
  1334 CREATE TABLE entities (
  1333 CREATE TABLE entities (
  1335   eid INTEGER PRIMARY KEY NOT NULL,
  1334   eid INTEGER PRIMARY KEY NOT NULL,
  1336   type VARCHAR(64) NOT NULL,
  1335   type VARCHAR(64) NOT NULL,
  1337   asource VARCHAR(128) NOT NULL,
       
  1338   extid VARCHAR(256)
  1336   extid VARCHAR(256)
  1339 );;
  1337 );;
  1340 CREATE INDEX entities_type_idx ON entities(type);;
  1338 CREATE INDEX entities_type_idx ON entities(type);;
  1341 
  1339 
  1342 CREATE TABLE transactions (
  1340 CREATE TABLE transactions (