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

Method as_sql

django/db/models/expressions.py:1171–1191  ·  view source on GitHub ↗
(self, compiler, connection)

Source from the content-addressed store, hash-verified

1169 return f"{self.__class__.__name__}({self.value!r})"
1170
1171 def as_sql(self, compiler, connection):
1172 connection.ops.check_expression_support(self)
1173 val = self.value
1174 output_field = self._output_field_or_none
1175 if output_field is not None:
1176 if self.for_save:
1177 val = output_field.get_db_prep_save(val, connection=connection)
1178 else:
1179 val = output_field.get_db_prep_value(val, connection=connection)
1180 try:
1181 get_placeholder_sql = output_field.get_placeholder_sql
1182 except AttributeError:
1183 pass
1184 else:
1185 return get_placeholder_sql(val, compiler, connection)
1186 if val is None:
1187 # oracledb does not always convert None to the appropriate
1188 # NULL type (like in case expressions using numbers), so we
1189 # use a literal SQL NULL
1190 return "NULL", ()
1191 return "%s", (val,)
1192
1193 def as_sqlite(self, compiler, connection, **extra_context):
1194 sql, params = self.as_sql(compiler, connection, **extra_context)

Callers 2

as_sqliteMethod · 0.95

Calls 3

get_db_prep_saveMethod · 0.45
get_db_prep_valueMethod · 0.45

Tested by 1