Skip to content

Commit

Permalink
fix: preserves objectids in deepCopyObject (#7385)
Browse files Browse the repository at this point in the history
## Description

The `deepCopyObject` function was cannibalizing ObjectIDs, which
conflicted with the ability to surface them from the MongoDB adapter.
Now, the `deepCopyObject` function will simply pass through ObjectIDs
rather than break them.
  • Loading branch information
jmikrut authored Jul 26, 2024
1 parent 5321098 commit 1348483
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/payload/src/utilities/deepCopyObject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import ObjectID from 'bson-objectid'

export const deepCopyObject = (inObject) => {
if (ObjectID.isValid(inObject)) return inObject

if (inObject instanceof Date) return inObject

if (inObject instanceof Set) return new Set(inObject)
Expand Down

0 comments on commit 1348483

Please sign in to comment.