8000 Add methods to copy documents/arrays by chilagrow · Pull Request #115 · FerretDB/wire · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 7 commits into from
May 27, 2025
Merged

Add methods to copy documents/arrays #115

merged 7 commits into from
May 27, 2025

Conversation

chilagrow
Copy link
Member

Closes #109.

@chilagrow chilagrow self-assigned this May 21, 2025
@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 08:28
@chilagrow chilagrow requested a review from AlekSi as a code owner May 21, 2025 08:28
@chilagrow chilagrow added the code/feature Some user-visible feature is not implemented yet label May 21, 2025
@chilagrow chilagrow marked this pull request as draft May 21, 2025 08:28
Copy link
@Copilot Copilot AI left a 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.

Copy link
codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.29%. Comparing base (efa7aa9) to head (f1bed42).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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              
Files with missing lines Coverage Δ
wirebson/array.go 53.03% <100.00%> (+4.26%) ⬆️
wirebson/document.go 52.02% <100.00%> (+3.25%) ⬆️

... and 1 file with indirect coverage changes

Flag Coverage Δ
test 59.29% <100.00%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chilagrow chilagrow changed the title Add function to copy array and document Add functions to copy array and document May 22, 2025
@chilagrow chilagrow marked this pull request as ready for review May 22, 2025 06:01
@chilagrow chilagrow requested review from a team and noisersup May 22, 2025 06:01
noisersup
noisersup previously approved these changes May 22, 2025
@chilagrow chilagrow enabled auto-merge (squash) May 23, 2025 05:22
@AlekSi AlekSi changed the title Add functions to copy array and document Add methods to copy documents/arrays May 27, 2025
Copy link
@Copilot Copilot AI left a 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 and Array.Copy with special handling for Binary slices.
  • Add TestDocumentCopy, TestArrayCopy, and a Copy subtest for RawDocument.
  • Update imports in tests to include time and require.

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 nested Document or Array elements. Add assertions to ensure that nested structures are (or are not) shared according to intended semantics.
func TestArrayCopy(t *testing.T) {

@chilagrow chilagrow merged commit b537191 into main May 27, 2025
11 checks passed
@chilagrow chilagrow deleted the copy-composites branch May 27, 2025 10:09
@github-project-automation github-project-automation bot moved this from In progress to Done in Current Engineering May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/feature Some user-visible feature is not implemented yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add methods to copy documents/arrays
3 participants
0