rset.py
changeset 3720 5376aaadd16b
parent 3629 559cad62c786
parent 3689 deb13e88e037
child 3777 3ef8cdb5fb1c
equal deleted inserted replaced
3678:29f74716fd70 3720:5376aaadd16b
   394             warn(msg, DeprecationWarning, stacklevel=3)
   394             warn(msg, DeprecationWarning, stacklevel=3)
   395             col = 0
   395             col = 0
   396         etype = self.description[row][col]
   396         etype = self.description[row][col]
   397         try:
   397         try:
   398             eschema = self.vreg.schema.eschema(etype)
   398             eschema = self.vreg.schema.eschema(etype)
   399             if eschema.is_final():
   399             if eschema.final:
   400                 raise NotAnEntity(etype)
   400                 raise NotAnEntity(etype)
   401         except KeyError:
   401         except KeyError:
   402             raise NotAnEntity(etype)
   402             raise NotAnEntity(etype)
   403         return self._build_entity(row, col)
   403         return self._build_entity(row, col)
   404 
   404 
   459             for i, attr, x in attr_desc_iterator(select, col):
   459             for i, attr, x in attr_desc_iterator(select, col):
   460                 outerselidx = rqlst.subquery_selection_index(select, i)
   460                 outerselidx = rqlst.subquery_selection_index(select, i)
   461                 if outerselidx is None:
   461                 if outerselidx is None:
   462                     continue
   462                     continue
   463                 if x == 'subject':
   463                 if x == 'subject':
   464                     rschema = eschema.subject_relation(attr)
   464                     rschema = eschema.subjrels[attr]
   465                     if rschema.is_final():
   465                     if rschema.final:
   466                         entity[attr] = rowvalues[outerselidx]
   466                         entity[attr] = rowvalues[outerselidx]
   467                         continue
   467                         continue
   468                     tetype = rschema.objects(etype)[0]
   468                     tetype = rschema.objects(etype)[0]
   469                     card = rschema.rproperty(etype, tetype, 'cardinality')[0]
   469                     card = rschema.rproperty(etype, tetype, 'cardinality')[0]
   470                 else:
   470                 else:
   471                     rschema = eschema.object_relation(attr)
   471                     rschema = eschema.objrels[attr]
   472                     tetype = rschema.subjects(etype)[0]
   472                     tetype = rschema.subjects(etype)[0]
   473                     card = rschema.rproperty(tetype, etype, 'cardinality')[1]
   473                     card = rschema.rproperty(tetype, etype, 'cardinality')[1]
   474                 # only keep value if it can't be multivalued
   474                 # only keep value if it can't be multivalued
   475                 if card in '1?':
   475                 if card in '1?':
   476                     if rowvalues[outerselidx] is None:
   476                     if rowvalues[outerselidx] is None:
   539     def related_entity(self, row, col):
   539     def related_entity(self, row, col):
   540         """try to get the related entity to extract format information if any"""
   540         """try to get the related entity to extract format information if any"""
   541         locate_query_col = col
   541         locate_query_col = col
   542         rqlst = self.syntax_tree()
   542         rqlst = self.syntax_tree()
   543         etype = self.description[row][col]
   543         etype = self.description[row][col]
   544         if self.vreg.schema.eschema(etype).is_final():
   544         if self.vreg.schema.eschema(etype).final:
   545             # final type, find a better one to locate the correct subquery
   545             # final type, find a better one to locate the correct subquery
   546             # (ambiguous if possible)
   546             # (ambiguous if possible)
   547             for i in xrange(len(rqlst.children[0].selection)):
   547             for i in xrange(len(rqlst.children[0].selection)):
   548                 if i == col:
   548                 if i == col:
   549                     continue
   549                     continue
   550                 coletype = self.description[row][i]
   550                 coletype = self.description[row][i]
   551                 if coletype is None:
   551                 if coletype is None:
   552                     continue
   552                     continue
   553                 if not self.vreg.schema.eschema(coletype).is_final():
   553                 if not self.vreg.schema.eschema(coletype).final:
   554                     etype = coletype
   554                     etype = coletype
   555                     locate_query_col = i
   555                     locate_query_col = i
   556                     if len(self.column_types(i)) > 1:
   556                     if len(self.column_types(i)) > 1:
   557                         break
   557                         break
   558         # UNION query, find the subquery from which this entity has been found
   558         # UNION query, find the subquery from which this entity has been found