Skip to content
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

feat(*): add Copy function that deep-copies a dataset #254

Open
ramfox opened this issue Apr 27, 2021 · 0 comments
Open

feat(*): add Copy function that deep-copies a dataset #254

ramfox opened this issue Apr 27, 2021 · 0 comments

Comments

@ramfox
Copy link
Member

ramfox commented Apr 27, 2021

Ran into a case in a test on qri where we needed to deep copy a dataset. We are relying on github.com/jinzhu/copier for this functionality, and it's working fine.

While working on the problem, I assumed that dataset.Assign() would create new copies of the dataset for me, in the same way that Assign works in javascript. This however, wasn't the case. Changing a field in an underlying component (such as ds.Structure.Format) would change the field in both datasets.

If we find that we end up needing to deep copy datasets more, we should add a copy function that behaves much in the way that our config.Copy works over in the config packages in qri: https://github.com/qri-io/qri/blob/master/config/config.go

// Copy returns a deep copy of the dataset structure
func (d *Dataset) Copy() *Dataset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant