MCPcopy
hub / github.com/tortoise/tortoise-orm / group_by

Method group_by

tortoise/queryset.py:643–651  ·  view source on GitHub ↗

Make QuerySet returns list of dict or tuple with group by. Must call before .values() or .values_list()

(self, *fields: str)

Source from the content-addressed store, hash-verified

641 return queryset
642
643 def group_by(self, *fields: str) -> QuerySet[MODEL]:
644 """
645 Make QuerySet returns list of dict or tuple with group by.
646
647 Must call before .values() or .values_list()
648 """
649 queryset = self._clone()
650 queryset._group_bys = fields
651 return queryset
652
653 def values_list(self, *fields_: str, flat: bool = False) -> ValuesListQuery[Literal[False]]:
654 """

Callers 15

test_group_byFunction · 0.80
test_count_group_byFunction · 0.80
test_sum_group_byFunction · 0.80
test_sum_filter_group_byFunction · 0.80
test_avg_group_byFunction · 0.80
test_avg_filter_group_byFunction · 0.80

Calls 1

_cloneMethod · 0.95

Tested by 15

test_group_byFunction · 0.64
test_count_group_byFunction · 0.64
test_sum_group_byFunction · 0.64
test_sum_filter_group_byFunction · 0.64
test_avg_group_byFunction · 0.64
test_avg_filter_group_byFunction · 0.64