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

Method get_fallback_sql

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

Source from the content-addressed store, hash-verified

242
243class TupleLessThan(TupleLookupMixin, LessThan):
244 def get_fallback_sql(self, compiler, connection):
245 # Process right-hand-side to trigger sanitization.
246 self.process_rhs(compiler, connection)
247 # e.g.: (a, b, c) < (x, y, z) as SQL:
248 # WHERE a < x OR (a = x AND (b < y OR (b = y AND c < z)))
249 lookups = itertools.cycle([LessThan, Exact])
250 connectors = itertools.cycle([OR, AND])
251 cols_list = [col for col in self.lhs for _ in range(2)]
252 vals_list = [val for val in self.rhs for _ in range(2)]
253 cols_iter = iter(cols_list[:-1])
254 vals_iter = iter(vals_list[:-1])
255 col = next(cols_iter)
256 val = next(vals_iter)
257 lookup = next(lookups)
258 connector = next(connectors)
259 root = node = WhereNode([lookup(col, val)], connector=connector)
260
261 for col, val in zip(cols_iter, vals_iter):
262 lookup = next(lookups)
263 connector = next(connectors)
264 child = WhereNode([lookup(col, val)], connector=connector)
265 node.children.append(child)
266 node = child
267
268 return root.as_sql(compiler, connection)
269
270
271class TupleLessThanOrEqual(TupleLookupMixin, LessThanOrEqual):

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