Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add group_by action method #28

Closed
Tracked by #116
RobertCraigie opened this issue Jun 21, 2021 · 6 comments · Fixed by #237
Closed
Tracked by #116

Add group_by action method #28

RobertCraigie opened this issue Jun 21, 2021 · 6 comments · Fixed by #237
Labels
kind/feature A request for a new feature.
Projects

Comments

@RobertCraigie
Copy link
Owner

RobertCraigie commented Jun 21, 2021

https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#groupby

The design decision we need to make here is how to represent the data that prisms returns.

@RobertCraigie RobertCraigie added the kind/feature A request for a new feature. label Jun 21, 2021
@RobertCraigie RobertCraigie added this to To do in v1.0.0 via automation Jun 21, 2021
@RobertCraigie RobertCraigie added this to the Public Release milestone Jul 6, 2021
@RobertCraigie RobertCraigie removed this from the Public Release milestone Aug 17, 2021
@RobertCraigie RobertCraigie added the process/candidate Candidate for the next release label Dec 13, 2021
@RobertCraigie RobertCraigie added this to the v0.5.0 milestone Dec 13, 2021
@RobertCraigie RobertCraigie removed the process/candidate Candidate for the next release label Jan 5, 2022
@RobertCraigie RobertCraigie removed this from the v0.4.3 milestone Jan 5, 2022
@HKGx
Copy link

HKGx commented Jan 18, 2022

any updates?

@RobertCraigie
Copy link
Owner Author

@HKGx Not yet, although this is not a difficult change. I'll work on it now.

@RobertCraigie
Copy link
Owner Author

@HKGx Do you need to also query by _count, _avg, _sum, _min or _max? (https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#groupby)

I forgot about these aggregation fields before mentioning that this is not a difficult change. Adding support for querying by these fields is more difficult due to internal features that I haven't implemented yet. If you don't need these, I can prioritise getting an initial proof of concept implemented which you would be able to use until the next release.

@HKGx
Copy link

HKGx commented Jan 18, 2022

@RobertCraigie I'd say so as I'm currently doing

SELECT field, COUNT(field) FROM table GROUP BY field

Not sure how it applies to Prisma, though.

@RobertCraigie
Copy link
Owner Author

@HKGx You would be correct, I'll see what I can do.

For reference, the missing internal feature is serializing queries for selecting fields (#19).

@RobertCraigie
Copy link
Owner Author

@HKGx I've added the initial support for this feature.

You can try it out by installing from the wip/group-by branch:

pip install -U git+https://github.com/RobertCraigie/prisma-client-py@wip/group-by

It should be noted that the group_by method returns a TypedDict, not a BaseModel.

This is also very much a work in progress, please let me know if you encounter any issues.

v1.0.0 automation moved this from To do to Done Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants