[SERVER-61079] Move TransactionsUtil.deepCopyObject into its own class Created: 28/Oct/21  Updated: 16/Dec/22  Resolved: 28/Oct/21

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

Type: Task Priority: Major - P3
Reporter: Haley Connelly Assignee: Backlog - Storage Execution Team
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-50501 Move TransactionsUtil.deepCopyObject ... Backlog
is related to SERVER-40425 fix Object.extend() for all custom ja... Backlog
Assigned Teams:
Storage Execution
Participants:

 Description   

(From what we can tell) TransactionsUtil. deepCopyObject is how some of the jstests do deep copies of objects. 

This article outlines what we discovered as a side effect of shallow copying in javascript.

It would be nice for this helper method to be separated from Transactions util (or to be pointed to a more preferable method of deep copying for our codebase).



 Comments   
Comment by Haley Connelly [ 28/Oct/21 ]

I didn't know Object.extend had the option for deep copy! Going to close this as won't do. Thanks for the quick feedback  

Comment by Max Hirschhorn [ 28/Oct/21 ]

I think if there's a goal to move TransactionsUtil.deepCopyObject({}, cmdObj) to a more common place then we should attempt to unify its interface with the pattern of Object.extend({}, cmdObj, true /* deep */). As a bit of history/context, the original deepCopyObject() function was written for SERVER-35037 because custom types like DB and DBCollection have underlying C++ data (the Mongo connection object) and cannot be copied through enumerating over all properties on the object. The deepCopyObject() function was then moved to become TransactionsUtil.deepCopyObject() in SERVER-38937 because Object.extend() doesn't handle other custom types like BinData and NumberInt which have underlying C++ data. We don't actually need to make copies of those values because they are effectively immutable (as far as the underlying C++ data is concerned).

I'd be concerned about proliferating more usages of TransactionsUtil.deepCopyObject() we had made for expediency over doing SERVER-40425.

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