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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying, Write Ops
    • None
    • Environment:
      GNU/Linux Ubuntu (Lucid) mongodb-unstable package (version 20100604)
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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

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

              Created:
              Updated:
              Resolved: