rqlrewrite.py
changeset 4908 b3ad329cbe17
parent 4907 e623afd49356
child 5004 4cc020ee70e2
child 5421 8167de96c523
equal deleted inserted replaced
4907:e623afd49356 4908:b3ad329cbe17
     9 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     9 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
    10 """
    10 """
    11 __docformat__ = "restructuredtext en"
    11 __docformat__ = "restructuredtext en"
    12 
    12 
    13 from rql import nodes as n, stmts, TypeResolverException
    13 from rql import nodes as n, stmts, TypeResolverException
    14 
    14 from yams import BadSchemaDefinition
    15 from logilab.common.graph import has_path
    15 from logilab.common.graph import has_path
    16 
    16 
    17 from cubicweb import Unauthorized, typed_eid
    17 from cubicweb import Unauthorized, typed_eid
    18 
    18 
    19 
    19 
   315             if rschema.final or (rschema.inlined and
   315             if rschema.final or (rschema.inlined and
   316                                  not rel in stinfo['rhsrelations']):
   316                                  not rel in stinfo['rhsrelations']):
   317                 rel.children[0].name = selectvar # XXX explain why
   317                 rel.children[0].name = selectvar # XXX explain why
   318                 subselect.add_restriction(rel.copy(subselect))
   318                 subselect.add_restriction(rel.copy(subselect))
   319                 for vref in rel.children[1].iget_nodes(n.VariableRef):
   319                 for vref in rel.children[1].iget_nodes(n.VariableRef):
       
   320                     if isinstance(vref.variable, n.ColumnAlias):
       
   321                         # XXX could probably be handled by generating the subquery
       
   322                         # into the detected subquery
       
   323                         raise BadSchemaDefinition(
       
   324                             "cant insert security because of usage two inlined "
       
   325                             "relations in this query. You should probably at "
       
   326                             "least uninline %s" % rel.r_type)
   320                     subselect.append_selected(vref.copy(subselect))
   327                     subselect.append_selected(vref.copy(subselect))
   321                     aliases.append(vref.name)
   328                     aliases.append(vref.name)
   322                 self.select.remove_node(rel)
   329                 self.select.remove_node(rel)
   323                 # when some inlined relation has to be copied in the subquery,
   330                 # when some inlined relation has to be copied in the subquery,
   324                 # we need to test that either value is NULL or that the snippet
   331                 # we need to test that either value is NULL or that the snippet