|
This happens when the document doesn't exist. This behavior has been fixed in 2.6.4:
> db.foo.update({_id: {year: 2012, url: {$exists: false}}}, {$inc: {bar: 1}}, {upsert: true})
|
WriteResult({
|
"nMatched" : 0,
|
"nUpserted" : 0,
|
"nModified" : 0,
|
"writeError" : {
|
"code" : 52,
|
"errmsg" : "The dollar ($) prefixed field '$exists' in '_id.url.$exists' is not valid for storage."
|
}
|
})
|
|
|
@aaron That's the syntaxe I use now, and it works well.
So I'm ok to let you open a ticket about preventing the insertion of field name containing the $ sign on update and close this one (with a link on the new ticket here for future readers).
Is there any kind of documentation somewhere about the fact that '_id: {url: {$exists: false}}' is inconsistent ?
I think that a link to it in the update page (and some other page) worth it.
|
|
Just to be clear, if the intention is for the query to specify that the _id.url field does not exist then the update would be
update( { '_id.year': 2012, '_id.url': {$exists: false} }, {$inc: {bar: 1}}, {upsert: true} )
|
and no $exists field is inserted
|
|
Hi Julien - Since your url field is inside _id, it's not treated as a separate query field but a sub field of the _id value the query will try to match.
For inserts we don't allow field names containing $ signs, but for updates we are not consistent about preventing this. I'll make sure we have a ticket open for the update discrepancies.
|
Generated at Thu Feb 08 03:17:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.