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

Method as_sql

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

Source from the content-addressed store, hash-verified

720 return bounds
721
722 def as_sql(self, compiler, connection):
723 # Avoid the extract operation if the rhs is a direct value to allow
724 # indexes to be used.
725 if self.rhs_is_direct_value():
726 # Skip the extract part by directly using the originating field,
727 # that is self.lhs.lhs.
728 lhs_sql, params = self.process_lhs(compiler, connection, self.lhs.lhs)
729 rhs_sql, _ = self.process_rhs(compiler, connection)
730 rhs_sql = self.get_direct_rhs_sql(connection, rhs_sql)
731 start, finish = self.year_lookup_bounds(connection, self.rhs)
732 params = (*params, *self.get_bound_params(start, finish))
733 return "%s %s" % (lhs_sql, rhs_sql), params
734 return super().as_sql(compiler, connection)
735
736 def get_direct_rhs_sql(self, connection, rhs):
737 return connection.operators[self.lookup_name] % rhs

Callers

nothing calls this directly

Calls 7

get_direct_rhs_sqlMethod · 0.95
year_lookup_boundsMethod · 0.95
get_bound_paramsMethod · 0.95
rhs_is_direct_valueMethod · 0.80
process_lhsMethod · 0.45
process_rhsMethod · 0.45
as_sqlMethod · 0.45

Tested by

no test coverage detected