Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-283

Collection.rename should return new collection by default

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0, 1.4.13
    • Affects Version/s: 1.4.12
    • Component/s: None
    • 1

      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

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            radekk Radoslaw Karpowicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: