Annotate result with aggregation or function result. :raises TypeError: Value of kwarg is expected to be a ``Function`` instance.
(self, **kwargs: Expression | Term)
| 625 | return self |
| 626 | |
| 627 | def annotate(self, **kwargs: Expression | Term) -> QuerySet[MODEL]: |
| 628 | """ |
| 629 | Annotate result with aggregation or function result. |
| 630 | |
| 631 | :raises TypeError: Value of kwarg is expected to be a ``Function`` instance. |
| 632 | """ |
| 633 | from tortoise.models import get_filters_for_field |
| 634 | |
| 635 | queryset = self._clone() |
| 636 | for key, annotation in kwargs.items(): |
| 637 | # if not isinstance(annotation, (Function, Term)): |
| 638 | # raise TypeError("value is expected to be Function/Term instance") |
| 639 | queryset._annotations[key] = annotation |
| 640 | queryset._custom_filters.update(get_filters_for_field(key, None, key)) |
| 641 | return queryset |
| 642 | |
| 643 | def group_by(self, *fields: str) -> QuerySet[MODEL]: |
| 644 | """ |
nothing calls this directly
no test coverage detected