Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4442

It is possible to rename a collection to an empty string

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.1.0
    • Affects Version/s: 2.0.1
    • Component/s: Usability
    • None
    • Environment:
      All
    • Minor Change
    • ALL

      Mongo does not allow the creation of collections with an empty string as the name, but it is possible to rename an existing collection to "".

      To reproduce:

      > db[""].save(

      {x:2}

      ) // it is not possible to create a new collection with an empty string as the name
      invalid ns: test.
      > db.getCollection("").save(

      {x:2}

      )
      invalid ns: test.
      > db.test.save(

      {x:2}

      ) // it is possible to rename an existing collection to an empty string
      > db.test.renameCollection("")

      { "ok" : 1 }

      > db[""].find()

      { "_id" : ObjectId("4ede683f5833a9b2c91c8dc0"), "x" : 2 }

      >

            Assignee:
            matulef Kevin Matulef
            Reporter:
            mbastien Marc Bastien
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: