insertMany failing when ordered : false and document key having a dot(.)

Using MongoDB Node.js Driver:

While running insertMany docs where one one of the docs is having key with a dot(.). Refer the document below.

E.g. var docs = [{ "name": "name1", age: "21" },
                { "na.me": "name2", age: "24" },
                { "name": "name3", age: "23" }]

When the option is selected as ordered: false, it should insert document name1, should fail document name2(as the key has a dot) and then insert document name3.

But in reality the entire insert fails without inserting any document with the below error.

Error: key na.me must not contain '.'
    at serializeInto (<path>\node_modules\bson\lib\bson\parser\serializer.js:913:19) 
    at serializeObject (<path>\node_modules\bson\lib\bson\parser\serializer.js:347:18    at serializeInto (<path>\node_modules\bson\lib\bson\parser\serializer.js:727:17) 
    at serializeObject (<path>\node_modules\bson\lib\bson\parser\serializer.js:347:18)
    at serializeInto (<path>\node_modules\bson\lib\bson\parser\serializer.js:937:17) 
)
    at serializeInto (<path>\node_modules\bson\lib\bson\parser\serializer.js:727:17) 
    at serializeObject (<path>\node_modules\bson\lib\bson\parser\serializer.js:347:18)
    at serializeInto (<path>\node_modules\bson\lib\bson\parser\serializer.js:937:17) 
    at BSON.serialize (<path>\node_modules\bson\lib\bson\bson.js:64:28)
    at Msg.serializeBson (<path>\node_modules\mongodb-core\lib\connection\msg.js:124:22)
    at Msg.makeDocumentSegment (<path>\node_modules\mongodb-core\lib\connection\msg.js:116:33)
    at Msg.toBin (<path>\node_modules\mongodb-core\lib\connection\msg.js:102:25)     
    at serializeCommand (<path>\node_modules\mongodb-core\lib\connection\pool.js:772:41)

Any help is appreciated.

Hello @Vyankatesh_Inamdar, welcome to the community!

There are open issues related to that on MongoDB JIRA:

That said, in the mongo shell (server v4.2.8) you can insert the documents with dot (.) in the field names without any errors. The field from the sample document you had posted shows as "na.me" : "name2" in the inserted document.

1 Like