Skip to content

Prevent mutation of original data structure in insert/create/insertOrUpdate#564

Merged
kiaking merged 7 commits into
vuex-orm:masterfrom
HamishBrindle:master
Mar 4, 2020
Merged

Prevent mutation of original data structure in insert/create/insertOrUpdate#564
kiaking merged 7 commits into
vuex-orm:masterfrom
HamishBrindle:master

Conversation

@HamishBrindle

Copy link
Copy Markdown
Contributor

Add cloning before normalizing and persisting records to prevent unwanted/unanticipated data mutation.

References: #516

Changes:

  • Add a cloning utility (quick and dirty, got it from 30 Seconds of Code)
  • Implement a cloning of input data before normalizing and persisting new records
  • Write tests for Create, Insert, and InsertOrUpdate to confirm original data is not mutated
  • Write tests for a cloning utility

Ensure the data going in is the same once all the operations have been
completed.
Prevent input's original structure from being modified by the
Normalizer.

resolves vuex-orm#516
@codecov

codecov Bot commented Feb 8, 2020

Copy link
Copy Markdown

Codecov Report

Merging #564 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #564   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         1837      1838    +1     
  Branches       255       255           
=========================================
+ Hits          1837      1838    +1     

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6ef777...63bfae4. Read the comment docs.

@cuebit cuebit added the enhancement New feature or request label Feb 8, 2020
@cuebit

cuebit commented Feb 8, 2020

Copy link
Copy Markdown
Member

Thanks so much, super helpful!

Could you import core-js/fn/array/from as a polyfill (src/polyfill/index.ts)? Much appreciated.

@cuebit cuebit added this to the v1.0.0 milestone Feb 8, 2020
@cuebit cuebit linked an issue Feb 8, 2020 that may be closed by this pull request
@HamishBrindle

Copy link
Copy Markdown
Contributor Author

@cuebit No worries, happy to help. And cool, polyfill added

There was a change in commit `011ea9ab60e799677b593398dd894d3350da7b8a` that 
got removed in a subsequent PR, and I'm not sure why, but this fixes the error when
getting related records
Revert "Update HasManyBy with null/undefined check"

This reverts commit 031df9a.
cuebit added a commit to cuebit/vuex-orm that referenced this pull request Feb 23, 2020
additionally fixes reference issues

resolves vuex-orm#553, vuex-orm#516
closes vuex-orm#564
cuebit added a commit to cuebit/vuex-orm that referenced this pull request Feb 23, 2020
additionally fixes reference issues

resolves vuex-orm#553, vuex-orm#516
closes vuex-orm#564
@kiaking kiaking merged commit f37c6f4 into vuex-orm:master Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The behavior change of insertOrUpdate is as expected?

3 participants