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

BREAKING CHANGE: Safer types for Model.distinct and Query.distinct. #13836

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

kaulsh
Copy link
Contributor

@kaulsh kaulsh commented Sep 7, 2023

Summary

W.r.t issue #11306

This PR improves the type safety for the return type of Model#distinct and Query#distinct. It should behave more like Mongodb does, i.e., if you give something that isn't a key on the document, you would still get an empty array or maybe something unknown[]. If you do give the correct key from the schema, you'll get a type safe result.

Note: This is not a backwards compatible change, as pointed out here: #11306 (comment)

Examples

The changes to the tests should be good enough examples. Can add more here if required.

@kaulsh kaulsh force-pushed the safer-distinct-return-type branch from 9856e47 to b951883 Compare September 7, 2023 16:15
@kaulsh kaulsh changed the title feat: Safer types for Model.distinct and Query.distinct. BREAKING CHANGE: Safer types for Model.distinct and Query.distinct. Sep 7, 2023
@vkarpov15 vkarpov15 changed the base branch from master to 8.0 September 8, 2023 14:03
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks. Merging this into 8.0 branch for next major release.

@vkarpov15 vkarpov15 added this to the 8.0 milestone Sep 8, 2023
@vkarpov15 vkarpov15 merged commit 1f79e2c into Automattic:8.0 Sep 8, 2023
3 checks passed
@kaulsh kaulsh deleted the safer-distinct-return-type branch September 8, 2023 14:55
vkarpov15 added a commit that referenced this pull request Jun 1, 2024
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