MCPcopy
hub / github.com/django/django / as_sql

Method as_sql

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

Source from the content-addressed store, hash-verified

386 return super().get_prep_lookup()
387
388 def as_sql(self, compiler, connection):
389 # Avoid comparison against direct rhs if lhs is a boolean value. That
390 # turns "boolfield__exact=True" into "WHERE boolean_field" instead of
391 # "WHERE boolean_field = True" when allowed.
392 if (
393 isinstance(self.rhs, bool)
394 and getattr(self.lhs, "conditional", False)
395 and connection.ops.conditional_expression_supported_in_where_clause(
396 self.lhs
397 )
398 ):
399 lhs_sql, params = self.process_lhs(compiler, connection)
400 template = "%s" if self.rhs else "NOT %s"
401 return template % lhs_sql, params
402 return super().as_sql(compiler, connection)
403
404
405@Field.register_lookup

Callers

nothing calls this directly

Calls 3

process_lhsMethod · 0.45
as_sqlMethod · 0.45

Tested by

no test coverage detected