Skip to content
Snippets Groups Projects
Commit 19ad9d65a95e authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Union.locate_subquery now return a 2-uple (select subquery, column index in the subquery)

parent 71f875e3e2c1
No related branches found
No related tags found
No related merge requests found
...@@ -275,8 +275,8 @@ ...@@ -275,8 +275,8 @@
def _locate_subquery(self, col, etype, kwargs): def _locate_subquery(self, col, etype, kwargs):
if len(self.children) == 1 and not self.children[0].with_: if len(self.children) == 1 and not self.children[0].with_:
return self.children[0] return self.children[0], col
for select in self.children: for select in self.children:
term = select.selection[col] term = select.selection[col]
try: try:
if term.name in select.aliases: if term.name in select.aliases:
...@@ -279,10 +279,11 @@ ...@@ -279,10 +279,11 @@
for select in self.children: for select in self.children:
term = select.selection[col] term = select.selection[col]
try: try:
if term.name in select.aliases: if term.name in select.aliases:
union = select.aliases[term.name].query alias = select.aliases[term.name]
return union._locate_subquery(col, etype, kwargs) return alias.query._locate_subquery(alias.colnum, etype,
kwargs)
except AttributeError: except AttributeError:
pass pass
for i, solution in enumerate(select.solutions): for i, solution in enumerate(select.solutions):
if term.get_type(solution, kwargs) == etype: if term.get_type(solution, kwargs) == etype:
...@@ -285,8 +286,8 @@ ...@@ -285,8 +286,8 @@
except AttributeError: except AttributeError:
pass pass
for i, solution in enumerate(select.solutions): for i, solution in enumerate(select.solutions):
if term.get_type(solution, kwargs) == etype: if term.get_type(solution, kwargs) == etype:
return select return select, col
raise Exception('internal error, %s not found on col %s' % (etype, col)) raise Exception('internal error, %s not found on col %s' % (etype, col))
def locate_subquery(self, col, etype, kwargs=None): def locate_subquery(self, col, etype, kwargs=None):
...@@ -290,6 +291,9 @@ ...@@ -290,6 +291,9 @@
raise Exception('internal error, %s not found on col %s' % (etype, col)) raise Exception('internal error, %s not found on col %s' % (etype, col))
def locate_subquery(self, col, etype, kwargs=None): def locate_subquery(self, col, etype, kwargs=None):
"""return a select node and associated selection index where root
variable at column `col` is of type `etype`
"""
try: try:
return self._subq_cache[(col, etype)] return self._subq_cache[(col, etype)]
except AttributeError: except AttributeError:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment