[SERVER-46695] Allow arrays creation during new record upsert when specifying dotted sub-paths inside $set:{} command Created: 06/Mar/20  Updated: 10/Mar/20  Resolved: 10/Mar/20

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

Type: New Feature Priority: Minor - P4
Reporter: Maximus N/A Assignee: Carl Champain (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13478 Resolve ambiguity of positional array... Backlog
Participants:

 Description   

Currently, mongoDB server creates object/hash by default during new record/element insertion when using dotted sub-paths inside $set:{} command:

collection.update(  
       { <search.filter> },
       { {$set:{"doc.1":{<doc-data>}} },
       { safe:true, upsert:true},
       function(err, ...

In this case, the following record is created:
{ "_id":<XXX>, ... , "doc" :

{ "1" : <doc-data> }

}

However, if the record is already created with doc=[] (array) element then the above update leads to an array update procedure.

MongoDB server should not desire by default that the doc is an object {} during record/element creation, because it can be an array too. Please add a new option like "CreateArrayOnInsert:true" so mongoDB server can create arrays[] if the element/record doesn't exist, like this:

collection.update(  
       { <search.filter> },
       { {$set:{"doc.1":{<doc-data>}} },
       { safe:true, upsert:true, CreateArrayOnInsert:true},
       function(err, ...

-> this should create a record with the following elements:

{ "_id":<XXX>, ... , "doc" : [ null, <doc-data> ] }

 Comments   
Comment by Carl Champain (Inactive) [ 10/Mar/20 ]

Sorry, I think this ticket is actually a duplicate of SERVER-13478 (I linked it as related to SERVER-13478 at first). Hence, I will close this one. If you really think this is not a duplicate, feel free to reopen and explain why.

Thank you,
Carl

Comment by Carl Champain (Inactive) [ 10/Mar/20 ]

Hi maxbanin79@gmail.com,

Thanks for the report.
We are passing this ticket along to the appropriate team for further investigation. Updates will be posted on this ticket as they happen.

Kind regards,
Carl
 

Generated at Thu Feb 08 05:12:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.