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

Method as_sql

django/db/models/sql/compiler.py:2233–2254  ·  view source on GitHub ↗

Create the SQL for this query. Return the SQL string and list of parameters.

(self)

Source from the content-addressed store, hash-verified

2231
2232class SQLAggregateCompiler(SQLCompiler):
2233 def as_sql(self):
2234 """
2235 Create the SQL for this query. Return the SQL string and list of
2236 parameters.
2237 """
2238 sql, params = [], []
2239 for annotation in self.query.annotation_select.values():
2240 ann_sql, ann_params = self.compile(annotation)
2241 ann_sql, ann_params = annotation.select_format(self, ann_sql, ann_params)
2242 sql.append(ann_sql)
2243 params.extend(ann_params)
2244 self.col_count = len(self.query.annotation_select)
2245 sql = ", ".join(sql)
2246 params = tuple(params)
2247
2248 inner_query_sql, inner_query_params = self.query.inner_query.get_compiler(
2249 self.using,
2250 elide_empty=self.elide_empty,
2251 ).as_sql(with_col_aliases=True)
2252 sql = "SELECT %s FROM (%s) subquery" % (sql, inner_query_sql)
2253 params += inner_query_params
2254 return sql, params
2255
2256
2257def cursor_iter(cursor, sentinel, col_count, itersize):

Callers

nothing calls this directly

Calls 8

extendMethod · 0.80
get_compilerMethod · 0.80
valuesMethod · 0.45
compileMethod · 0.45
select_formatMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
as_sqlMethod · 0.45

Tested by

no test coverage detected