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

Commit 27d2426a by Sushant

fix(#5092): passing model and option to getWhereConditions in deleteQuery

1 parent 5ad75762
# FUTURE # Future
- [ADDED] Support silent: true in bulk update [#5200](https://github.com/sequelize/sequelize/issues/5200) - [ADDED] Support silent: true in bulk update [#5200](https://github.com/sequelize/sequelize/issues/5200)
- [FIXED] Postgres destroy with `where` fails on JSONB data [#5092](https://github.com/sequelize/sequelize/issues/5092)
# 3.17.3 # 3.17.3
- [FIXED] Regression with array values from security fix in 3.17.2 - [FIXED] Regression with array values from security fix in 3.17.2
......
...@@ -375,7 +375,7 @@ var QueryGenerator = { ...@@ -375,7 +375,7 @@ var QueryGenerator = {
var replacements = { var replacements = {
table: this.quoteIdentifiers(tableName), table: this.quoteIdentifiers(tableName),
where: this.getWhereConditions(where), where: this.getWhereConditions(where, null, model, options),
limit: !!options.limit ? ' LIMIT ' + this.escape(options.limit) : '', limit: !!options.limit ? ' LIMIT ' + this.escape(options.limit) : '',
primaryKeys: primaryKeys[tableName].length > 1 ? '(' + pks + ')' : pks, primaryKeys: primaryKeys[tableName].length > 1 ? '(' + pks + ')' : pks,
primaryKeysSelection: pks primaryKeysSelection: pks
......
...@@ -312,6 +312,14 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -312,6 +312,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
it('should be possible to destroy with where', function () { it('should be possible to destroy with where', function () {
var conditionSearch = {
where: {
data: {
employment : 'Hacker'
}
}
};
return Promise.join( return Promise.join(
this.Event.create({ this.Event.create({
data: { data: {
...@@ -330,15 +338,22 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -330,15 +338,22 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}, },
employment: 'Hacker' employment: 'Hacker'
} }
}) }),
).bind(this).then(function () { this.Event.create({
return this.Event.destroy({
where: {
data: { data: {
employment : 'Hacker' name: {
} first: ' Tyrell',
last: 'Wellick'
},
employment: 'CTO'
} }
}); })
).bind(this).then(function () {
return expect(this.Event.findAll(conditionSearch)).to.eventually.have.length(2);
}).then(function() {
return this.Event.destroy(conditionSearch);
}).then(function(){
return expect(this.Event.findAll(conditionSearch)).to.eventually.have.length(0);
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!