[server.querier] construct ExecutionPlan from schema since querier is not needed
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Wed, 13 Mar 2019 11:06:46 +0100
changeset 12889 bbf3e56b43fe
parent 12888 24a20d2b8c84
child 12890 0cd5b9057202
[server.querier] construct ExecutionPlan from schema since querier is not needed
cubicweb/server/querier.py
--- a/cubicweb/server/querier.py	Wed Feb 19 19:49:01 2020 +0100
+++ b/cubicweb/server/querier.py	Wed Mar 13 11:06:46 2019 +0100
@@ -154,7 +154,8 @@
 class ExecutionPlan(object):
     """the execution model of a rql query, composed of querier steps"""
 
-    def __init__(self, querier, rqlst, args, cnx):
+    def __init__(self, schema, rqlst, args, cnx):
+        self.schema = schema
         # original rql syntax tree
         self.rqlst = rqlst
         self.args = args or {}
@@ -162,7 +163,6 @@
         self.cnx = cnx
         # execution steps
         self.steps = []
-        self.querier = querier
         # tracing token for debugging
         self.rql_query_tracing_token = None
 
@@ -211,8 +211,8 @@
             noinvariant = ()
         if cached is None:
             self.cnx.vreg.rqlhelper.simplify(union)
-            RQLAnnotator(self.querier.schema).annotate(union)
-            set_qdata(self.querier.schema.rschema, union, noinvariant)
+            RQLAnnotator(self.schema).annotate(union)
+            set_qdata(self.schema.rschema, union, noinvariant)
         if union.has_text_query:
             self.cache_key = None
 
@@ -308,7 +308,7 @@
             for sol in solutions:
                 sol[newvarname] = nvartype
         select.clean_solutions(solutions)
-        add_types_restriction(self.querier.schema, select)
+        add_types_restriction(self.schema, select)
         self.cnx.vreg.rqlhelper.annotate(rqlst)
         self.preprocess(rqlst, security=False)
         return rqlst
@@ -318,8 +318,8 @@
     """an execution model specific to the INSERT rql query
     """
 
-    def __init__(self, querier, rqlst, args, cnx):
-        ExecutionPlan.__init__(self, querier, rqlst, args, cnx)
+    def __init__(self, schema, rqlst, args, cnx):
+        ExecutionPlan.__init__(self, schema, rqlst, args, cnx)
         # save originally selected variable, we may modify this
         # dictionary for substitution (query parameters)
         self.selected = rqlst.selection
@@ -339,7 +339,7 @@
     def add_relation_def(self, rdef):
         """add an relation definition to build"""
         edef, rtype, value = rdef
-        if self.querier.schema[rtype].rule:
+        if self.schema[rtype].rule:
             raise QueryError("'%s' is a computed relation" % rtype)
         self.r_defs.add(rdef)
         if not isinstance(edef, int):
@@ -487,8 +487,8 @@
     def plan_factory(self, rqlst, args, cnx):
         """create an execution plan for an INSERT RQL query"""
         if rqlst.TYPE == 'insert':
-            return InsertPlan(self, rqlst, args, cnx)
-        return ExecutionPlan(self, rqlst, args, cnx)
+            return InsertPlan(self.schema, rqlst, args, cnx)
+        return ExecutionPlan(self.schema, rqlst, args, cnx)
 
     @statsd_timeit
     def execute(self, cnx, rql, args=None, build_descr=True):