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

Method process_rhs

django/db/models/lookups.py:514–538  ·  view source on GitHub ↗
(self, compiler, connection)

Source from the content-addressed store, hash-verified

512 return super().get_prep_lookup()
513
514 def process_rhs(self, compiler, connection):
515 db_rhs = getattr(self.rhs, "_db", None)
516 if db_rhs is not None and db_rhs != connection.alias:
517 raise ValueError(
518 "Subqueries aren't allowed across different databases. Force "
519 "the inner query to be evaluated using `list(inner_query)`."
520 )
521
522 if self.rhs_is_direct_value():
523 # Remove None from the list as NULL is never equal to anything.
524 try:
525 rhs = OrderedSet(self.rhs)
526 rhs.discard(None)
527 except TypeError: # Unhashable items in self.rhs
528 rhs = [r for r in self.rhs if r is not None]
529
530 if not rhs:
531 raise EmptyResultSet
532
533 # rhs should be an iterable; use batch_process_rhs() to
534 # prepare/transform those values.
535 sqls, sqls_params = self.batch_process_rhs(compiler, connection, rhs)
536 placeholder = "(" + ", ".join(sqls) + ")"
537 return (placeholder, sqls_params)
538 return super().process_rhs(compiler, connection)
539
540 def get_rhs_op(self, connection, rhs):
541 return "IN %s" % rhs

Callers 15

as_sqlMethod · 0.45
process_rhsMethod · 0.45
as_postgresqlMethod · 0.45
process_rhsMethod · 0.45
process_rhsMethod · 0.45
process_rhsMethod · 0.45
as_sqlMethod · 0.45
as_sqlMethod · 0.45
process_rhsMethod · 0.45
as_sqlMethod · 0.45
as_oracleMethod · 0.45
as_sqlMethod · 0.45

Calls 5

discardMethod · 0.95
OrderedSetClass · 0.90
rhs_is_direct_valueMethod · 0.80
batch_process_rhsMethod · 0.45
joinMethod · 0.45

Tested by 8

as_sqlMethod · 0.36
as_oracleMethod · 0.36
as_sqlMethod · 0.36
as_sqlMethod · 0.36
as_sqlMethod · 0.36
as_sqlMethod · 0.36
as_custom_sqlMethod · 0.36
as_custom_sqlMethod · 0.36