db.abc.update({}, {$rename:{"YR..MODA":"YRMODA"}}, false, true);The update path 'YR..MODAHRMN' contains an empty field name, which is not allowed.Hi Shekhar,
Thank you for bringing this to our attention. I have opened two tickets on MongoDB issue tracker based on this.
1. $rename being unable to rename fields with dots: SERVER-25164
An alternative solution to remove the field with the dot and re-add it without the dot using cursor .forEach:
db.test.find().forEach( function(myDoc) {
myDoc.ab = myDoc["a.b"];
delete myDoc["a.b"];
db.test.save(myDoc);
} );
I tested this against the current version (3.2.8) and I suggest that you test it for your specific use case and data sets.
2. Prevent importing field names with dots for mongoimport: TOOLS-1335.
Please keep in mind that rmongodb is a community-supported driver, if it allows fields with dot to be inserted then you may want to raise an issue ticket on rmongodb project issues. Also you may consider using mongolite package which is more actively maintained.
—
Regards,
Amar