MCPcopy
hub / github.com/django/django / process_rhs

Method process_rhs

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

Source from the content-addressed store, hash-verified

335 )
336
337 def process_rhs(self, compiler, connection):
338 if not self.rhs_is_direct_value():
339 return super(TupleLookupMixin, self).process_rhs(compiler, connection)
340
341 rhs = self.rhs
342 if not rhs:
343 raise EmptyResultSet
344
345 # e.g.: (a, b, c) in [(x1, y1, z1), (x2, y2, z2)] as SQL:
346 # WHERE (a, b, c) IN ((x1, y1, z1), (x2, y2, z2))
347 result = []
348 lhs = self.lhs
349
350 for vals in rhs:
351 # Remove any tuple containing None from the list as NULL is never
352 # equal to anything.
353 if any(val is None for val in vals):
354 continue
355 result.append(
356 Tuple(
357 *[
358 (
359 val
360 if hasattr(val, "as_sql")
361 else Value(val, output_field=col.output_field)
362 )
363 for col, val in zip(lhs, vals)
364 ]
365 )
366 )
367
368 if not result:
369 raise EmptyResultSet
370
371 return compiler.compile(Tuple(*result))
372
373 def get_fallback_sql(self, compiler, connection):
374 rhs = self.rhs

Callers 6

process_rhsMethod · 0.45
get_fallback_sqlMethod · 0.45
get_fallback_sqlMethod · 0.45
get_fallback_sqlMethod · 0.45
get_fallback_sqlMethod · 0.45
get_fallback_sqlMethod · 0.45

Calls 5

ValueClass · 0.90
TupleClass · 0.85
rhs_is_direct_valueMethod · 0.80
appendMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected