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

Create previousAttributes using a deep clone of attributes #1876

Merged
merged 1 commit into from Nov 4, 2018

Conversation

@okuyiga
Copy link

@okuyiga okuyiga commented Jul 8, 2018

Introduction

Altered Model._reset to use a deep clone so that changes to Model.attributes don't affect Model._previousAttributes.

Motivation

Problem is detailed in #1875.

Proposed solution

Use _.cloneDeep. Fixes #1875.

Current PR Issues

None

Alternatives considered

None

Copy link
Member

@ricardograca ricardograca left a comment

Everything looks good except for the test description which seems a bit misleading and could lead to confusion further down the road.

@@ -52,6 +52,20 @@ module.exports = function(bookshelf) {
});
});

it('can update attributes without affecting _previousAttributes', function() {

This comment has been minimized.

@ricardograca

ricardograca Jul 9, 2018
Member

I'm not sure this description fits with what is actually being tested here. It should be the opposite since previousAttributes will now detect changes to nested objects.

@ricardograca ricardograca added this to To Do in Version 0.14.0 via automation Jul 9, 2018
@ricardograca
Copy link
Member

@ricardograca ricardograca commented Nov 4, 2018

I'm going to merge this as is and then change the description of the test in another PR.

@ricardograca ricardograca merged commit 32add1b into bookshelf:master Nov 4, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Version 0.14.0 automation moved this from To Do to Done Nov 4, 2018
@ricardograca
Copy link
Member

@ricardograca ricardograca commented Nov 4, 2018

Renamed in fc66733.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants