-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
API: Do count distinct since left join
duplicates results
#19208
API: Do count distinct since left join
duplicates results
#19208
Conversation
🦋 Changeset detectedLatest commit: fbaf31e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
LGTM so far, but would be great to have this covered in a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thank you both! ❤️
…#19208) * Do count distinct since `left join` duplicates results * Add changeset * Correctly access count property * Update .changeset/angry-suits-compete.md * Optimize for simple filters * Add tests * Workaround broken 'as' for countDistinct in SQLite3 --------- Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: ian <licitdev@gmail.com>
…#19208) * Do count distinct since `left join` duplicates results * Add changeset * Correctly access count property * Update .changeset/angry-suits-compete.md * Optimize for simple filters * Add tests * Workaround broken 'as' for countDistinct in SQLite3 --------- Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: ian <licitdev@gmail.com>
Motivation
In some scenarios,
filter_count
returns the result of the amount of relationships instead of just the amount records on current collection.This happens because the results are duplicated since a
left join
is being used.Solution
In order to solve this, we can just do a
countDistinct
using the primary key of the current collection.That will remove the duplicated results and
filter_count
will have proper valueFixes #18608