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

Insert creates the _id field, always

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • None
    • None
    • Storage
    • None
    • Minor Change
    • ALL

    Description

      Not sure how to insert a document with no _id in the shell, so this example uses PyMongo. In 2.4.x, if I create a collection with autoIndexId set to false I can insert a document without an _id field and the _id is not automatically created:

      >>> c = pymongo.MongoClient()
      >>> db = c.test
      >>> coll = db.create_collection("test", capped=True, autoIndexId=False, size=1000)
      >>> coll.insert({'a': 'a'}, manipulate=False)
      >>> coll.find_one()
      {u'a': u'a'}
      >>> c.server_info()['version']
      u'2.4.8'

      In 2.5.5-pre- the _id field is created, regardless of the autoIndexId setting:

      >>> c = pymongo.MongoClient()
      >>> db = c.test
      >>> coll = db.create_collection("test", capped=True, autoIndexId=False, size=1000)
      >>> coll.insert({'a': 'a'}, manipulate=False)
      >>> coll.find_one()
      {u'a': u'a', u'_id': ObjectId('52d0831332e6147c55bbd61b')}
      >>> c.server_info()['version']
      u'2.5.5-pre-'

      Attachments

        Issue Links

          Activity

            People

              eliot Eliot Horowitz (Inactive)
              bernie@mongodb.com Bernie Hackett
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: