[SERVER-7474] Upsert With Modifiers In Find Throws Exception Created: 25/Oct/12  Updated: 07/Mar/14  Resolved: 29/Oct/12

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.0.0, 2.2.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: William Watson Assignee: Andrew Emil (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

centos, mongo command-line client, mongo ruby driver


Operating System: Linux
Participants:

 Description   

This may affect more versions, but I've only tested on 2.2.0 and 2.0.0.

Trying to do an upsert with a $not modifier in the find:

db.counters.update({"_id" : {a: 5, b:10}, "$not":{"value.tx":"5d"}}, {"$inc":{"value.c":4}, "$set":{"value.tx":"5d"}}, true)

Works for the first insert. But the second always fails with the following exception, no matter what $not is set to:

E11000 duplicate key error index: databaseone.counters.$_id_  dup key: { : { a: 5.0, b: 10.0 } }



 Comments   
Comment by William Watson [ 29/Oct/12 ]

db.counters.find({"value.tx" : { $ne: "5d" }}) or
db.counters.find({"value.tx" : { $not: /5d/ }})

Comment by William Watson [ 29/Oct/12 ]

Well outside of the fact that your query is completely wrong (syntax error, $not can only be used as a meta operator which I did not know), it did lead us in the right direction so thanks!

Comment by Eliot Horowitz (Inactive) [ 29/Oct/12 ]

Problem is that the query is invalid.
Want:
{"_id" :

{a: 5, b:10}

, "value.tx :

{ "$not": "5d"}

}

Generated at Thu Feb 08 03:14:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.