server/sources/pyrorql.py
branchstable
changeset 3016 5787d1cc8106
parent 2763 39b42e158249
child 3043 7bcb7f1c0f46
equal deleted inserted replaced
3015:0588e39f6743 3016:5787d1cc8106
    23 from cubicweb import dbapi, server
    23 from cubicweb import dbapi, server
    24 from cubicweb import BadConnectionId, UnknownEid, ConnectionError
    24 from cubicweb import BadConnectionId, UnknownEid, ConnectionError
    25 from cubicweb.cwconfig import register_persistent_options
    25 from cubicweb.cwconfig import register_persistent_options
    26 from cubicweb.server.sources import (AbstractSource, ConnectionWrapper,
    26 from cubicweb.server.sources import (AbstractSource, ConnectionWrapper,
    27                                      TimedCache, dbg_st_search, dbg_results)
    27                                      TimedCache, dbg_st_search, dbg_results)
       
    28 
       
    29 
       
    30 def uidtype(union, col, etype, args):
       
    31     select, col = union.locate_subquery(col, etype, args)
       
    32     return getattr(select.selection[col], 'uidtype', None)
       
    33 
    28 
    34 
    29 class ReplaceByInOperator(Exception):
    35 class ReplaceByInOperator(Exception):
    30     def __init__(self, eids):
    36     def __init__(self, eids):
    31         self.eids = eids
    37         self.eids = eids
    32 
    38 
   293         descr = rset.description
   299         descr = rset.description
   294         if rset:
   300         if rset:
   295             needtranslation = []
   301             needtranslation = []
   296             rows = rset.rows
   302             rows = rset.rows
   297             for i, etype in enumerate(descr[0]):
   303             for i, etype in enumerate(descr[0]):
   298                 if (etype is None or not self.schema.eschema(etype).is_final() or
   304                 if (etype is None or not self.schema.eschema(etype).is_final()
   299                     getattr(union.locate_subquery(i, etype, args).selection[i], 'uidtype', None)):
   305                     or uidtype(union, i, etype, args)):
   300                     needtranslation.append(i)
   306                     needtranslation.append(i)
   301             if needtranslation:
   307             if needtranslation:
   302                 cnx = session.pool.connection(self.uri)
   308                 cnx = session.pool.connection(self.uri)
   303                 for rowindex in xrange(rset.rowcount - 1, -1, -1):
   309                 for rowindex in xrange(rset.rowcount - 1, -1, -1):
   304                     row = rows[rowindex]
   310                     row = rows[rowindex]