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

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() { ...@@ -332,7 +332,7 @@ module.exports = (function() {
} }
// If attempting to set read only attributes, return // 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; return;
} }
......
...@@ -48,7 +48,9 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -48,7 +48,9 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
identifier: {type: DataTypes.STRING, primaryKey: true} identifier: {type: DataTypes.STRING, primaryKey: true}
}); });
var user = User.build(); var user = User.build({}, {
isNewRecord: false
});
user.set({ user.set({
createdAt: new Date(2000, 1, 1), createdAt: new Date(2000, 1, 1),
...@@ -66,7 +68,9 @@ describe(Support.getTestDialectTeaser('DAO'), function() { ...@@ -66,7 +68,9 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
underscored: true underscored: true
}); });
var user = User.build(); var user = User.build({}, {
isNewRecord: false
});
user.set({ user.set({
created_at: new Date(2000, 1, 1), 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!