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

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

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.6.2
    • Component/s: Write Ops
    • Labels:
      None
    • Environment:
      mongodb 1.6.2, pymongo-1.8.1, python 2.6
    • Query
    • OS X

      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.

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

              Created:
              Updated:
              Resolved: