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

Mongoose "converts" string to ObjectId for properties of type ObjectId #6742

Closed
Ncifra opened this issue Jul 19, 2018 · 2 comments
Closed

Mongoose "converts" string to ObjectId for properties of type ObjectId #6742

Ncifra opened this issue Jul 19, 2018 · 2 comments
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation

Comments

@Ncifra
Copy link

Ncifra commented Jul 19, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When sending a string value that is 12 characters long, the "ObjectId" validation seems to be bypassed. We have tried with "Select Type:" and "Select Typ18" (not that they should be relevant I think), and these values are "saved" as ObjectId's inside the schema. The ObjectId's are actually random, even though that actual property refers to an external id from another schema.

If the current behavior is a bug, please provide the steps to reproduce.
I think the above description is explanatory.

What is the expected behavior?
An error of "Cast to ObjectID failed for value ..." should be thrown.

Please mention your node.js, mongoose and MongoDB version.
Node: 6.9.1
Mongoose: 4.13.11
MongoDB: 3.4

@lineus lineus added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Jul 19, 2018
@lineus
Copy link
Collaborator

lineus commented Jul 19, 2018

@Ncifra please see #1959 for an explanation of why this isn't a bug. We should add this to the FAQ. I'm leaving this open to track that.

@lineus lineus self-assigned this Jul 19, 2018
@lineus lineus removed their assignment Jul 19, 2018
@Ncifra
Copy link
Author

Ncifra commented Jul 20, 2018

Yes, I expected this to be something "normal", considering the stored ObjectID's are 24 characters long, while this one is half, so there was some relation.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

2 participants