tortoise / tortoise/tortoise-orm

Fix joined annotations for `value` and `value_list` — was: Grouped aggregations

Open
#324 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Is your feature request related to a problem? Please describe.
I would like to group the table by a field and apply aggregations. Example SQL:

SELECT SUM(`column_1`)
FROM `table`
WHERE `column_2` = 'something'
GROUP BY `column_3`

Describe the solution you'd like
I'm not familiar with the code-base of this project yet, so I won't be able to propose an implementation.

Describe alternatives you've considered
Django's solution looks nice:

Author.objects.values('name').annotate(average_rating=Avg('book__rating'))

Additional context
If grouped aggregations already exists, I couldn't find it in the documentation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are identified in the issue. Review the ORM's existing annotation and grouping behavior, then verify that the SQL and Django-style aggregation examples work or that the documentation explains their availability.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.