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

Fields dropped when using update with $set

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.8.1
    • Component/s: Write Ops
    • Environment:
      Ubuntu lucid deb from website, db version v1.8.1, pdfile version 4.5
      Mon Jun 6 22:06:15 git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04
    • Linux

      Certain key values are lost with no warning when using $set to update a document. The following snippet illustrates:

      import pymongo

      document = {}
      for x in range(3000):
      document['%04X' % x] = "Hello"

      collection = pymongo.Connection().test_db.data
      spec = dict(_id = "unique_id")

      1. Make sure document is empty
        collection.remove(spec)
      1. Make a new document
        collection.save(spec)

      print "Length of document %s" % len(document)

      collection.update(spec,

      {"$set": document}

      , upsert=False, safe=True)

      result = collection.find_one(spec)
      print "Length of stored data %s" % len(result)

      for key in document:
      if key not in result:
      print "Key %s is missing" % key

      This is the output

      Length of document 3000
      Length of stored data 2981
      Key 00A7 is missing
      Key 00A6 is missing
      Key 00A5 is missing
      Key 00A4 is missing
      Key 00A3 is missing
      Key 00A2 is missing
      Key 00A1 is missing
      Key 00A0 is missing
      Key 00A9 is missing
      Key 00A8 is missing
      Key 00B2 is missing
      Key 00B3 is missing
      Key 00B0 is missing
      Key 00B1 is missing
      Key 00B6 is missing
      Key 00B7 is missing
      Key 00B4 is missing
      Key 00B5 is missing
      Key 00B8 is missing
      Key 00B9 is missing

      Changing the formatter from %04X to %04d seems to bypass the issue. So there is something about a pattern in the text.

            Assignee:
            Unassigned Unassigned
            Reporter:
            scudette Michael Cohen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: