server/ssplanner.py
changeset 2650 18aec79ec3a3
parent 2596 d02eed70937f
child 2667 c8aa82538d8e
equal deleted inserted replaced
2649:5d4a943695d1 2650:18aec79ec3a3
   112     def build_insert_plan(self, plan, rqlst):
   112     def build_insert_plan(self, plan, rqlst):
   113         """get an execution plan from an INSERT RQL query"""
   113         """get an execution plan from an INSERT RQL query"""
   114         # each variable in main variables is a new entity to insert
   114         # each variable in main variables is a new entity to insert
   115         to_build = {}
   115         to_build = {}
   116         session = plan.session
   116         session = plan.session
       
   117         etype_class = session.vreg['etypes'].etype_class
   117         for etype, var in rqlst.main_variables:
   118         for etype, var in rqlst.main_variables:
   118             # need to do this since entity class is shared w. web client code !
   119             # need to do this since entity class is shared w. web client code !
   119             to_build[var.name] = session.etype_class(etype)(session, None, None)
   120             to_build[var.name] = etype_class(etype)(session)
   120             plan.add_entity_def(to_build[var.name])
   121             plan.add_entity_def(to_build[var.name])
   121         # add constant values to entity def, mark variables to be selected
   122         # add constant values to entity def, mark variables to be selected
   122         to_select = plan.relation_definitions(rqlst, to_build)
   123         to_select = plan.relation_definitions(rqlst, to_build)
   123         # add necessary steps to add relations and update attributes
   124         # add necessary steps to add relations and update attributes
   124         step = InsertStep(plan) # insert each entity and its relations
   125         step = InsertStep(plan) # insert each entity and its relations