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

Commit c44c72ae by Mirko Jotic Committed by Sushant

fix(instance): isSoftDelete true after creating (#10799)

1 parent 4cc7dc8a
...@@ -4057,7 +4057,7 @@ class Model { ...@@ -4057,7 +4057,7 @@ class Model {
const deletedAtAttribute = this.constructor.rawAttributes[this.constructor._timestampAttributes.deletedAt]; const deletedAtAttribute = this.constructor.rawAttributes[this.constructor._timestampAttributes.deletedAt];
const defaultValue = deletedAtAttribute.hasOwnProperty('defaultValue') ? deletedAtAttribute.defaultValue : null; const defaultValue = deletedAtAttribute.hasOwnProperty('defaultValue') ? deletedAtAttribute.defaultValue : null;
const deletedAt = this.get(this.constructor._timestampAttributes.deletedAt); const deletedAt = this.get(this.constructor._timestampAttributes.deletedAt) || null;
const isSet = deletedAt !== defaultValue; const isSet = deletedAt !== defaultValue;
return isSet; return isSet;
......
...@@ -594,6 +594,12 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -594,6 +594,12 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
return this.ParanoidUser.sync({ force: true }); return this.ParanoidUser.sync({ force: true });
}); });
it('should return false when model is just created', function() {
return this.ParanoidUser.create({ username: 'foo' }).then(user => {
expect(user.isSoftDeleted()).to.be.false;
});
});
it('returns false if user is not soft deleted', function() { it('returns false if user is not soft deleted', function() {
return this.ParanoidUser.create({ username: 'fnord' }).then(() => { return this.ParanoidUser.create({ username: 'fnord' }).then(() => {
return this.ParanoidUser.findAll().then(users => { return this.ParanoidUser.findAll().then(users => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!