MCPcopy
hub / github.com/django/django / add_annotation

Method add_annotation

django/db/models/sql/query.py:1239–1249  ·  view source on GitHub ↗

Add a single annotation expression to the Query.

(self, annotation, alias, select=True)

Source from the content-addressed store, hash-verified

1237 )
1238
1239 def add_annotation(self, annotation, alias, select=True):
1240 """Add a single annotation expression to the Query."""
1241 self.check_alias(alias)
1242 annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None)
1243 if select:
1244 self.append_annotation_mask([alias])
1245 else:
1246 self.set_annotation_mask(set(self.annotation_select).difference({alias}))
1247 self.annotations[alias] = annotation
1248 if select and self.selected:
1249 self.selected[alias] = alias
1250
1251 @property
1252 def _subquery_fields_len(self):

Callers 10

checkMethod · 0.95
test_q_annotationMethod · 0.95
_annotateMethod · 0.80
get_order_byMethod · 0.80
collect_replacementsMethod · 0.80
get_aggregationMethod · 0.80
existsMethod · 0.80

Calls 5

check_aliasMethod · 0.95
set_annotation_maskMethod · 0.95
resolve_expressionMethod · 0.45
differenceMethod · 0.45

Tested by 4

test_q_annotationMethod · 0.76