[SERVER-4830] Reject upsert if would create duplicate field names Created: 31/Jan/12  Updated: 08/Apr/23  Resolved: 14/Nov/13

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

Type: Bug Priority: Critical - P2
Reporter: Mathias Stearn Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-6835 Sharding edge case upserts documents ... Closed
Duplicate
is duplicated by SERVER-11514 segfault on upsert with conflicting f... Closed
is duplicated by SERVER-11363 Update call causes mongod to crash Closed
Related
related to SERVER-75879 Upsert permits document to contain mu... Closed
Operating System: ALL
Participants:

 Description   

> db.foo.drop()
true
> db.foo.update({'a.b':1, 'a.c':1}, {$inc:{z:1}}, true) // Works
> db.foo.find()
{ "_id" : ObjectId("4f286edcf2d87b48ed83cb08"), "a" : { "b" : 1, "c" : 1 }, "z" : 1 }
> db.foo.update({'a':{b:1}, 'a.c':1}, {$inc:{z:1}}, true) // Boom!
> db.foo.find()
{ "_id" : ObjectId("4f286edcf2d87b48ed83cb08"), "a" : { "b" : 1, "c" : 1 }, "z" : 1 }
{ "_id" : ObjectId("4f286efef2d87b48ed83cb09"), "a" : { "b" : 1 }, "a" : { "b" : 1 }, "z" : 1 }

The last one is actually

{a: {b:1}, a: {c:1}}

, but printjson function doesn't handle duplicate field names correctly (not sure if it is possible from JS).



 Comments   
Comment by Githook User [ 14/Nov/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-11531, SERVER-10489, SERVER-6835, SERVER-4830: Refactor update system to support immutable fields, consolodate storage validation, and misc issues.
Branch: master
https://github.com/mongodb/mongo/commit/b98712c551e8ab27c33e1a5e7c694fa36c3334ce

Comment by auto [ 06/Aug/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-4830: fix update+upsert insert case to preserve query fields
Branch: master
https://github.com/mongodb/mongo/commit/ae9604709b5594a5c05e5ddeb7c7d0ea71b3230c

Comment by auto [ 01/Aug/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-4830: filter out !okForStorage parts from query on update+upsert
Branch: master
https://github.com/mongodb/mongo/commit/a54de9ea07fa12fd1126b1ebe7ae4daa72640859

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