[SERVER-8526] Validate modifiers for updates, error if invalid. Created: 12/Feb/13  Updated: 06/Dec/22  Resolved: 28/Jun/17

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

Type: Bug Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 0
Labels: api, validation
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-8512 support $slice/sort in $addToSet Closed
is related to SERVER-6399 Refactor update() code Closed
Assigned Teams:
Query
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

For modifiers like $addToSet/$inc/$push/etc if there are invalid options ($fields included) then generate an error.

> db.c.update({}, {$addToSet:{a: {$foo:1, $each :[], $sort:..., $slice:... }}})



 Comments   
Comment by Asya Kamsky [ 28/Jun/17 ]

I believe this has been fixed a while back:

db.a.update({_id:1}, {$push:{a:{$foo:1, $each:[]}}})
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 2,
		"errmsg" : "Unrecognized clause in $push: $foo"
	}
})

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