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

fix: remove WithId from find filter type #3044

Closed
wants to merge 1 commit into from

Conversation

avaly
Copy link
Contributor

@avaly avaly commented Nov 18, 2021

Description

What is changing?

Fixes a regression in the find() filter TypeScript type.

Is there new documentation needed for these changes?

No.

What is the motivation for this change?

I believe there was a bug introduced in the #3039 PR: https://github.com/mongodb/node-mongodb-native/pull/3039/files#r752006554

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@PaulEndri
Copy link
Contributor

db.collection.find({_id: 'something'}) is a valid find operation in mongo itself and it's why it was added to the filter definition. This probably needs to get fixed by making whatever downstream incompatibility was accidentally caused by this change, compatible with the new definition.

@dariakp dariakp added the External Submission PR submitted from outside the team label Nov 18, 2021
@dariakp
Copy link
Contributor

dariakp commented Nov 18, 2021

@avaly Thanks for catching the inconsistency! I think the correct approach would be to add the WithId<TSchema> handling to the Filter type definition itself, so that it automatically propagates to the operations that should support it. As @PaulEndri mentioned, the _id is a valid filter option regardless of whether you explicitly specify it in your schema, since you can search on it even if it's auto-generated by the server. I think we didn't catch the omission earlier because we currently have the TSchema permitting all string keys, but it would be more correct to be explicit about the _id type (via WithId) than just letting it fall through. Do you have any concerns about taking that path forward?

@avaly
Copy link
Contributor Author

avaly commented Nov 18, 2021

@dariakp @PaulEndri you both make sense! I agree that maybe this should be solved inside of the Filter type.

Feel free to close this PR.

@dariakp
Copy link
Contributor

dariakp commented Nov 18, 2021

@avaly Alright, I created NODE-3770 to track the work to add consistent handling, closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Submission PR submitted from outside the team
Projects
None yet
3 participants