Skip to content

Commit

Permalink
fix(model): properly serialize WHERE attributes in soft delete (#8383)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabegorelick authored and sushantdhiman committed Sep 29, 2017
1 parent 107502e commit ba7aa33
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3788,7 +3788,7 @@ class Model {
this.setDataValue(field, values[field]);

return this.sequelize.getQueryInterface().update(
this, this.constructor.getTableName(options), values, where, _.defaults({ hooks: false }, options)
this, this.constructor.getTableName(options), values, where, _.defaults({ hooks: false, model: this.constructor }, options)
).then(results => {
const rowsUpdated = results[1];
if (this.constructor._versionAttribute && rowsUpdated < 1) {
Expand Down
26 changes: 26 additions & 0 deletions test/integration/instance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,32 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
});
});

if (dialect.match(/^postgres/)) {
it('converts Infinity in where clause to a timestamp', function() {
const Date = this.sequelize.define('Date',
{
date: {
type: DataTypes.DATE,
primaryKey: true
},
deletedAt: {
type: DataTypes.DATE,
defaultValue: Infinity
}
},
{ paranoid: true });

return this.sequelize.sync({ force: true })
.then(() => {
return Date.build({ date: Infinity })
.save()
.then(date => {
return date.destroy();
});
});
});
}
});

describe('isSoftDeleted', () => {
Expand Down

0 comments on commit ba7aa33

Please sign in to comment.