-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.4.12
-
Component/s: None
-
1
-
Empty show more show less
When using Collection.rename original object is modified by 'self.collectionName = newName' and it breaks other rename operations. When you try to execute rename() on the same object twice it will try to do:
1. A.rename('B'); <--- it renames 'A' to 'B'
2. A.rename('B'); <--- it renames 'B' to 'B' because collectionName property of object was modified.
It took me few hours to fix this behavior by setting
{new_collection: true}option as parameter. It should be set by default as posted here: https://jira.mongodb.org/browse/CASBAH-22
"To clarify: rename should NOT mutate the collection, but return a new collection instance pointing at the new name."
Broken source (line 108): https://github.com/mongodb/node-mongodb-native/blob/master/lib%2Fmongodb%2Fcollection%2Fcommands.js#L108