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

Use subqueries in Flop.count for queries with group_by #336

Merged
merged 6 commits into from
Jun 18, 2023

Conversation

michallepicki
Copy link
Contributor

@michallepicki michallepicki commented May 26, 2023

See also related discussion

@woylie woylie self-requested a review May 26, 2023 23:58
lib/flop.ex Outdated Show resolved Hide resolved
@woylie
Copy link
Owner

woylie commented May 27, 2023

Nice, thanks, we just need some tests 👍

@codecov
Copy link

codecov bot commented May 27, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09 🎉

Comparison is base (f587432) 88.29% compared to head (5d62388) 88.38%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #336      +/-   ##
==========================================
+ Coverage   88.29%   88.38%   +0.09%     
==========================================
  Files          13       13              
  Lines         880      887       +7     
==========================================
+ Hits          777      784       +7     
  Misses        103      103              
Impacted Files Coverage Δ
lib/flop.ex 94.70% <100.00%> (+0.12%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@michallepicki
Copy link
Contributor Author

Looks like we don't need to wrap queries with distinct, from Ecto.Repo.aggregate docs:

If the query has a limit, offset, distinct or combination set, it will be automatically wrapped in a subquery in order to return the proper result.

Maybe this was different in the past and that's why Scrivener had a special case for this. I'll remove this part.

Ecto will wrap the query in a subquery in Repo.aggregate
@michallepicki michallepicki marked this pull request as ready for review June 18, 2023 14:21
lib/flop.ex Outdated Show resolved Hide resolved
@woylie woylie merged commit fa196d9 into woylie:main Jun 18, 2023
@woylie
Copy link
Owner

woylie commented Jun 18, 2023

Thank you!

@michallepicki michallepicki deleted the subquery-group-by branch September 3, 2023 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants