Refs #373 -- Refactored variable assignments in ColPairs and tuple lookups.

This commit is contained in:
Bendeguz Csirmaz 2024-09-10 23:09:16 +08:00 committed by Sarah Boyce
parent 347ab72c02
commit 727587c089
2 changed files with 27 additions and 13 deletions

View File

@ -1332,7 +1332,9 @@ class Col(Expression):
class ColPairs(Expression):
def __init__(self, alias, targets, sources, output_field):
super().__init__(output_field=output_field)
self.alias, self.targets, self.sources = alias, targets, sources
self.alias = alias
self.targets = targets
self.sources = sources
def __len__(self):
return len(self.targets)

View File

@ -83,12 +83,15 @@ class TupleGreaterThan(TupleLookupMixin, GreaterThan):
vals_list = [val for val in self.rhs for _ in range(2)]
cols_iter = iter(cols_list[:-1])
vals_iter = iter(vals_list[:-1])
col, val = next(cols_iter), next(vals_iter)
lookup, connector = next(lookups), next(connectors)
col = next(cols_iter)
val = next(vals_iter)
lookup = next(lookups)
connector = next(connectors)
root = node = WhereNode([lookup(col, val)], connector=connector)
for col, val in zip(cols_iter, vals_iter):
lookup, connector = next(lookups), next(connectors)
lookup = next(lookups)
connector = next(connectors)
child = WhereNode([lookup(col, val)], connector=connector)
node.children.append(child)
node = child
@ -107,12 +110,15 @@ class TupleGreaterThanOrEqual(TupleLookupMixin, GreaterThanOrEqual):
vals_list = [val for val in self.rhs for _ in range(2)]
cols_iter = iter(cols_list)
vals_iter = iter(vals_list)
col, val = next(cols_iter), next(vals_iter)
lookup, connector = next(lookups), next(connectors)
col = next(cols_iter)
val = next(vals_iter)
lookup = next(lookups)
connector = next(connectors)
root = node = WhereNode([lookup(col, val)], connector=connector)
for col, val in zip(cols_iter, vals_iter):
lookup, connector = next(lookups), next(connectors)
lookup = next(lookups)
connector = next(connectors)
child = WhereNode([lookup(col, val)], connector=connector)
node.children.append(child)
node = child
@ -131,12 +137,15 @@ class TupleLessThan(TupleLookupMixin, LessThan):
vals_list = [val for val in self.rhs for _ in range(2)]
cols_iter = iter(cols_list[:-1])
vals_iter = iter(vals_list[:-1])
col, val = next(cols_iter), next(vals_iter)
lookup, connector = next(lookups), next(connectors)
col = next(cols_iter)
val = next(vals_iter)
lookup = next(lookups)
connector = next(connectors)
root = node = WhereNode([lookup(col, val)], connector=connector)
for col, val in zip(cols_iter, vals_iter):
lookup, connector = next(lookups), next(connectors)
lookup = next(lookups)
connector = next(connectors)
child = WhereNode([lookup(col, val)], connector=connector)
node.children.append(child)
node = child
@ -155,12 +164,15 @@ class TupleLessThanOrEqual(TupleLookupMixin, LessThanOrEqual):
vals_list = [val for val in self.rhs for _ in range(2)]
cols_iter = iter(cols_list)
vals_iter = iter(vals_list)
col, val = next(cols_iter), next(vals_iter)
lookup, connector = next(lookups), next(connectors)
col = next(cols_iter)
val = next(vals_iter)
lookup = next(lookups)
connector = next(connectors)
root = node = WhereNode([lookup(col, val)], connector=connector)
for col, val in zip(cols_iter, vals_iter):
lookup, connector = next(lookups), next(connectors)
lookup = next(lookups)
connector = next(connectors)
child = WhereNode([lookup(col, val)], connector=connector)
node.children.append(child)
node = child