-
Notifications
You must be signed in to change notification settings - Fork 6
Add methods to copy documents/arrays #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a Copy method for the Array type that returns a shallow copy while handling scalar values and Binary types appropriately. It also updates the import block to include the necessary packages to support the new functionality.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #115 +/- ##
==========================================
+ Coverage 58.99% 59.29% +0.29%
==========================================
Files 42 42
Lines 2717 2739 +22
==========================================
+ Hits 1603 1624 +21
- Misses 891 892 +1
Partials 223 223
... and 1 file with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds Copy
methods to the Document
and Array
types to enable shallow cloning (with deep copy of Binary
data) and introduces tests verifying this behavior across BSON types.
- Implement
Document.Copy
andArray.Copy
with special handling forBinary
slices. - Add
TestDocumentCopy
,TestArrayCopy
, and aCopy
subtest forRawDocument
. - Update imports in tests to include
time
andrequire
.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
wirebson/document.go | Added Document.Copy to clone documents |
wirebson/array.go | Added Array.Copy to clone arrays |
wirebson/document_test.go | New TestDocumentCopy verifying shallow copy logic |
wirebson/array_test.go | New TestArrayCopy verifying shallow copy logic |
wirebson/bson_test.go | Added RawDocument copy subtest |
Comments suppressed due to low confidence (1)
wirebson/array_test.go:51
- Tests cover top-level copy and
Binary
deep-clone but do not verify behavior of nestedDocument
orArray
elements. Add assertions to ensure that nested structures are (or are not) shared according to intended semantics.
func TestArrayCopy(t *testing.T) {
Closes #109.