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

Commit a87ecac4 by Mick Hansen

fix(instance): allow setting of readOnlyAttributes when isNewRecord: true

1 parent 5d32d667
Showing with 7 additions and 3 deletions
......@@ -332,7 +332,7 @@ module.exports = (function() {
}
// If attempting to set read only attributes, return
if (this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) {
if (!this.isNewRecord && this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) {
return;
}
......
......@@ -48,7 +48,9 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
identifier: {type: DataTypes.STRING, primaryKey: true}
});
var user = User.build();
var user = User.build({}, {
isNewRecord: false
});
user.set({
createdAt: new Date(2000, 1, 1),
......@@ -66,7 +68,9 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
underscored: true
});
var user = User.build();
var user = User.build({}, {
isNewRecord: false
});
user.set({
created_at: new Date(2000, 1, 1),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!