[SERVER-29819] Can create invalid dbref using $unset, but not $set Created: 23/Jun/17  Updated: 30/Oct/23  Resolved: 30/Jun/17

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 3.5.10

Type: Bug Priority: Major - P3
Reporter: Tess Avitabile (Inactive) Assignee: Tess Avitabile (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-29162 UpdateNode implementation should only... Closed
Related
is related to SERVER-29831 Can create invalid dbref using insert Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2017-07-10
Participants:

 Description   

We disallow creating an invalid dbref using $set:

> db.coll.update({}, {$set: {a: {$ref: "c", $db: "test"}}})
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 55,
		"errmsg" : "The DBRef $ref field must be following by a $id field"
	}
})

But it is allowed using $unset:

> db.coll.insert({a: {$ref: "c", $id: 0, $db: "test"}})
WriteResult({ "nInserted" : 1 })
> db.coll.update({}, {$unset: {"a.$id": true}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.coll.find()
{ "_id" : ObjectId("594d2381ae497a9bea475a71"), "a" : { "$ref" : "c", "$db" : "test" } }



 Comments   
Comment by Tess Avitabile (Inactive) [ 30/Jun/17 ]

Resolved by SERVER-28762 and unit tested in SERVER-29162.

Comment by Tess Avitabile (Inactive) [ 23/Jun/17 ]

Should be resolved for the new update system implementation in SERVER-29162.

Generated at Thu Feb 08 04:21:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.