MCPcopy
hub / github.com/django/django / as_postgresql

Method as_postgresql

django/contrib/postgres/fields/ranges.py:245–260  ·  view source on GitHub ↗
(self, compiler, connection)

Source from the content-addressed store, hash-verified

243 return super().process_rhs(compiler, connection)
244
245 def as_postgresql(self, compiler, connection):
246 sql, params = super().as_postgresql(compiler, connection)
247 # Cast the rhs if needed.
248 cast_sql = ""
249 if (
250 isinstance(self.rhs, models.Expression)
251 and self.rhs._output_field_or_none
252 and
253 # Skip cast if rhs has a matching range type.
254 not isinstance(
255 self.rhs._output_field_or_none, self.lhs.output_field.__class__
256 )
257 ):
258 cast_internal_type = self.lhs.output_field.base_field.get_internal_type()
259 cast_sql = "::{}".format(connection.data_types.get(cast_internal_type))
260 return "%s%s" % (sql, cast_sql), params
261
262
263DateRangeField.register_lookup(DateTimeRangeContains)

Callers

nothing calls this directly

Calls 3

get_internal_typeMethod · 0.45
formatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected