equal
deleted
inserted
replaced
155 """ |
155 """ |
156 newvar = _add_rtype_relation(rqlst, mainvar, rtype, role) |
156 newvar = _add_rtype_relation(rqlst, mainvar, rtype, role) |
157 if rqlst.groupby: |
157 if rqlst.groupby: |
158 rqlst.add_group_var(newvar) |
158 rqlst.add_group_var(newvar) |
159 rqlst.add_selected(newvar) |
159 rqlst.add_selected(newvar) |
|
160 # add is restriction if necessary |
|
161 if mainvar.stinfo['typerel'] is None: |
|
162 etypes = frozenset(sol[mainvar.name] for sol in rqlst.solutions) |
|
163 rqlst.add_type_restriction(mainvar, etypes) |
160 return newvar |
164 return newvar |
161 |
165 |
162 def _remove_relation(rqlst, rel, var): |
166 def _remove_relation(rqlst, rel, var): |
163 """remove a constraint relation from the syntax tree""" |
167 """remove a constraint relation from the syntax tree""" |
164 # remove the relation |
168 # remove the relation |
208 rqlst.add_group_var(attrvar) |
212 rqlst.add_group_var(attrvar) |
209 if sortasc is not None: |
213 if sortasc is not None: |
210 _set_orderby(rqlst, attrvar, sortasc, sortfuncname) |
214 _set_orderby(rqlst, attrvar, sortasc, sortfuncname) |
211 # add attribute variable to selection |
215 # add attribute variable to selection |
212 rqlst.add_selected(attrvar) |
216 rqlst.add_selected(attrvar) |
213 # add is restriction if necessary |
|
214 if mainvar.stinfo['typerel'] is None: |
|
215 etypes = frozenset(sol[mainvar.name] for sol in rqlst.solutions) |
|
216 rqlst.add_type_restriction(mainvar, etypes) |
|
217 return var |
217 return var |
218 |
218 |
219 def _cleanup_rqlst(rqlst, mainvar): |
219 def _cleanup_rqlst(rqlst, mainvar): |
220 """cleanup tree from unnecessary restriction: |
220 """cleanup tree from unnecessary restriction: |
221 * attribute selection |
221 * attribute selection |