Add a single annotation expression to the Query.
(self, annotation, alias, select=True)
| 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): |