不要怂,就是干,撸起袖子干!

Commit 436cd12e by Mick Hansen

Merge pull request #4967 from sorin/master

Failing .set test
2 parents feeff9ef 8727c817
Showing with 17 additions and 0 deletions
......@@ -232,6 +232,8 @@ var Utils = module.exports = {
return uuid.v4();
} else if (value instanceof DataTypes.NOW) {
return Utils.now();
} else if(_.isPlainObject(value) || _.isArray(value)) {
return _.clone(value);
} else {
return value;
}
......
......@@ -28,6 +28,21 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
expect(user.dataValues['meta.location']).not.to.be.ok;
expect(user.get('meta').location).to.equal('Copenhagen');
expect(user.get('meta') === meta).to.equal(true);
expect(user.get('meta') === meta).to.equal(true);
});
it('doesnt mutate the JSONB defaultValue', function() {
var User = current.define('User', {
meta: {
type: DataTypes.JSONB,
allowNull: false,
defaultValue: {}
}
});
var user1 = User.build({});
user1.set('meta.location', 'Stockhollm');
var user2 = User.build({});
expect(user2.get('meta')).to.deep.equal({});
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!