fix(database): Add groupBy after distinct queries (option 2) #20125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative solution: #20124
What does it do?
After performing a query that is supposed to be
distinct
but should actually probably be agroupBy
, we apply the same groupBy on the resultset received, in Node rather than the db query.NOTE: on further review and discussion, this will probably break pagination with a resultset that exceeds the size of one page.
Why is it needed?
Fixes #11892
How to test it?
See the original issue.
A test of
sort
has been added to prevent regressions, but this may have unintended side effects that are not caught by existing tests, so a pretty thorough test of nested populates and queries with joins and distincts that aren't the typical path we use.Related issue(s)/PR(s)
Alternative solution: #20124
Fixes #11892
DX-117