MCPcopy
hub / github.com/django/django / get_fallback_sql

Method get_fallback_sql

django/db/models/fields/tuple_lookups.py:188–212  ·  view source on GitHub ↗
(self, compiler, connection)

Source from the content-addressed store, hash-verified

186
187class TupleGreaterThan(TupleLookupMixin, GreaterThan):
188 def get_fallback_sql(self, compiler, connection):
189 # Process right-hand-side to trigger sanitization.
190 self.process_rhs(compiler, connection)
191 # e.g.: (a, b, c) > (x, y, z) as SQL:
192 # WHERE a > x OR (a = x AND (b > y OR (b = y AND c > z)))
193 lookups = itertools.cycle([GreaterThan, Exact])
194 connectors = itertools.cycle([OR, AND])
195 cols_list = [col for col in self.lhs for _ in range(2)]
196 vals_list = [val for val in self.rhs for _ in range(2)]
197 cols_iter = iter(cols_list[:-1])
198 vals_iter = iter(vals_list[:-1])
199 col = next(cols_iter)
200 val = next(vals_iter)
201 lookup = next(lookups)
202 connector = next(connectors)
203 root = node = WhereNode([lookup(col, val)], connector=connector)
204
205 for col, val in zip(cols_iter, vals_iter):
206 lookup = next(lookups)
207 connector = next(connectors)
208 child = WhereNode([lookup(col, val)], connector=connector)
209 node.children.append(child)
210 node = child
211
212 return root.as_sql(compiler, connection)
213
214
215class TupleGreaterThanOrEqual(TupleLookupMixin, GreaterThanOrEqual):

Callers

nothing calls this directly

Calls 4

WhereNodeClass · 0.90
process_rhsMethod · 0.45
appendMethod · 0.45
as_sqlMethod · 0.45

Tested by

no test coverage detected