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

Commit ba7aa331 by Gabe Gorelick Committed by Sushant

fix(model): properly serialize WHERE attributes in soft delete (#8383)

1 parent 107502e3
Showing with 27 additions and 1 deletions
......@@ -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) {
......
......@@ -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', () => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!