server/querier.py
branchstable
changeset 5596 d66a5d98db5b
parent 5426 0d4853a6e5ee
child 5657 8f56691f01de
equal deleted inserted replaced
5593:f6c55bec9326 5596:d66a5d98db5b
   267                 nbtrees = len(localchecks)
   267                 nbtrees = len(localchecks)
   268                 myunion = union
   268                 myunion = union
   269                 # transform in subquery when len(localchecks)>1 and groups
   269                 # transform in subquery when len(localchecks)>1 and groups
   270                 if nbtrees > 1 and (select.orderby or select.groupby or
   270                 if nbtrees > 1 and (select.orderby or select.groupby or
   271                                     select.having or select.has_aggregat or
   271                                     select.having or select.has_aggregat or
       
   272                                     select.distinct or
   272                                     select.limit or select.offset):
   273                                     select.limit or select.offset):
   273                     newselect = Select()
   274                     newselect = Select()
   274                     # only select variables in subqueries
   275                     # only select variables in subqueries
   275                     origselection = select.selection
   276                     origselection = select.selection
   276                     select.select_only_variables()
   277                     select.select_only_variables()
   301                     if select.offset:
   302                     if select.offset:
   302                         newselect.offset = select.offset
   303                         newselect.offset = select.offset
   303                         select.offset = 0
   304                         select.offset = 0
   304                     myunion = Union()
   305                     myunion = Union()
   305                     newselect.set_with([SubQuery(aliases, myunion)], check=False)
   306                     newselect.set_with([SubQuery(aliases, myunion)], check=False)
       
   307                     newselect.distinct = select.distinct
   306                     solutions = [sol.copy() for sol in select.solutions]
   308                     solutions = [sol.copy() for sol in select.solutions]
   307                     cleanup_solutions(newselect, solutions)
   309                     cleanup_solutions(newselect, solutions)
   308                     newselect.set_possible_types(solutions)
   310                     newselect.set_possible_types(solutions)
   309                     # if some solutions doesn't need rewriting, insert original
   311                     # if some solutions doesn't need rewriting, insert original
   310                     # select as first union subquery
   312                     # select as first union subquery