[SERVER-41628] The dollar ($) prefixed field is not valid for storage Created: 11/Jun/19  Updated: 08/Feb/22  Resolved: 11/Jun/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 3.4.7
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Muthu Prabu Assignee: Danny Hatcher (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

MongoDB does not allowed to store a key prefixed with dollar symbol.
Eg.

{'$push' : {'$in' : [200, 201]}}

Error message is: 

MongoError: The dollar ($) prefixed field '$in'  is not valid for storage.

In my case, this was happened when trying to update a document which is already exist.



 Comments   
Comment by Jeffrey Yemin [ 08/Feb/22 ]

Note that now, as per Restrictions on Field Names:

The server permits storage of field names that contain dots (.) and dollar signs ($).

Comment by Danny Hatcher (Inactive) [ 11/Jun/19 ]

Per our documentation on field name restrictions:

Top-level field names cannot start with the dollar sign ($) character.
Otherwise, starting in MongoDB 3.6, the server permits storage of field names that contain dots (i.e. .) and dollar signs (i.e. $).

The MongoDB Query Language cannot always meaningfully express queries over documents whose field names contain these characters (see SERVER-30575).
Until support is added in the query language, the use of $ and . in field names is not recommended and is not supported by the official MongoDB drivers.

Please note, the SERVER project is for bugs and feature suggestions for the MongoDB server. As this ticket does not appear to a bug, I will now close it. If you need further assistance troubleshooting, I encourage you to ask our community by posting on the mongodb-user group or on Stack Overflow with the mongodb tag.

Generated at Thu Feb 08 04:58:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.