-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
allow $ in field name #13202
base: devel
Are you sure you want to change the base?
allow $ in field name #13202
Conversation
@@ -1910,10 +1910,9 @@ const NO_CREATE_MODIFIERS = { | |||
}; | |||
|
|||
// Make sure field names do not contain Mongo restricted | |||
// characters ('.', '$', '\0'). | |||
// characters ('.', '\0'). | |||
// https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names |
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.
This PR looks good to me. However, I'm curious about the explicit prohibition of the dollar sign in minimongo. The documentation attached to the code mentions field name restrictions in Mongo, so it might just be an implementation based on those rules on the past, without other reasons behind.
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.
Before version 5 of mongodb, it didn't accept dot and dollar sign in field name, but now it does.
I think @hwillson added these verification to minimongo 8 years ago because Meteor allows us to insert data to minimongo and it will auto sync with mongodb in server (insecure package).
Btw, I'm thinking adding commits to also allow dot in field name but maybe do it in other PR.
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.
Thank you for the context provided. Now, I remember some use cases faced on the past with "$" and ".". It is ok to have these unlocked.
It seems like there are still quite a few limitations on For the tests you removed of cases minimongo did not allow, did you try them in Mongo to verify they should be allowed? It seems to fully support |
I agreed that if you want to easily work with data in minimongo, you will need that. |
Anyway, it would be good to have test coverage with the new case, to also verify the server side, and all this flow you describe. This will verify it is usable in this way, and we have both mongo driver on server and minimingo supporting the use case. |
It has, I added test to make sure we can insert object which has $ sign in key. |
Mongodb now supports field names with dollar signs:
https://www.mongodb.com/docs/manual/core/dot-dollar-considerations/#std-label-crud-concepts-dot-dollar-considerations