Skip to content

GROUP BY, HAVING and aggregation functions support #266

@MIREX

Description

@MIREX

Describe the solution you'd like
GROUP BY, HAVING and aggregation functions (such as count, avg, max and so on) support in queries. It could be very useful for making queries like this:

# Select all users with votes and count votes for each user
select user.id, count(vote.id) as votes_count
from user
         left join vote on user.id = vote.user
group by user.id
having votes_count > 0;

Before ormar I used to use peewee and I really like a way how it implemented there.

I think it could be easily implemented for queries returning raw values. But it could be a problem with dynamic assigning of Pydantic model fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions