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

Iterating through a query result and adding new data to the queried objects results in iterating over some objects twice

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying, Write Ops
    • None
    • GNU/Linux Ubuntu (Lucid) mongodb-unstable package (version 20100604)

    Description

      Iterating through a resultset and adding news fields to the objects results in a corrupted iterator.

      A simple test like the following code iterates many times over the same objects ... am I missing something? (see the attached file for a complete example)

        1. sample code ##
          total_obj = db.test.find().count()
          count = 0
          for item in db.test.find():
          db.test.update( {'_id':_id}

          , {'$set' : {'some_new_data' : random.randint(0, 1000)}})
          count = count +1

      print count,total_obj

        1. /sample code ##

      script usage:
      python mongo_find_and_update.py test_db

      Attachments

        Activity

          People

            eliot Eliot Horowitz (Inactive)
            alain Alan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: