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

$or paired with upsert does not create documents for each or clause

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • 1.6.2
    • Write Ops
    • None
    • mongodb 1.6.2, pymongo-1.8.1, python 2.6
    • Query
    • OS X

    Description

      When multiple keys are put together with an $or expression and the upsert flag is sent to update (and the multi flag is set) objects are not created for the items in the $or expression.

      This code using pymongo:

      keys = []
      for item in items:
      key =

      { 'a : item.a, 'b' : item.b, 'c' : item.c }

      keys.append(key)

      if len(keys) == 0:
      return

      query =

      { '$or' : keys }

      value = {
      '$inc' :

      { 'count' : 1 }

      }

      db.abc_counts.update(query, value, upsert=True, multi=True)

      Produces this in the DB:

      { "_id" : ObjectId("4c8e7161010f681721439e58"), "count" : 1 }

      if i replace query with keys[0] it works as expected.

      Attachments

        Activity

          People

            backlog-server-query Backlog - Query Team (Inactive)
            jeff jeff jenkins
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: