Skip to content

Commit

Permalink
Pulled changes in from sequelize:master
Browse files Browse the repository at this point in the history
  • Loading branch information
EToreo committed Jan 20, 2016
2 parents c1fc0fa + eca0a90 commit 9ad93d2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# FUTURE
# Future
- [ADDED] Support silent: true in bulk update [#5200](https://github.com/sequelize/sequelize/issues/5200)
- [ADDED] `retry` object now part of global settings and can be overridden per call. The default is 5 retries with a backoff function. `retry` object can be passed to options with max: 0 to turn off this behavior.
- [ADDED] Sqlite now retries database queries that return SQL_BUSY as the status.
- [FIXED] Postgres destroy with `where` fails on JSONB data [#5092](https://github.com/sequelize/sequelize/issues/5092)

# 3.17.3
- [FIXED] Regression with array values from security fix in 3.17.2
Expand Down
2 changes: 1 addition & 1 deletion lib/dialects/postgres/query-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ var QueryGenerator = {

var replacements = {
table: this.quoteIdentifiers(tableName),
where: this.getWhereConditions(where),
where: this.getWhereConditions(where, null, model, options),
limit: !!options.limit ? ' LIMIT ' + this.escape(options.limit) : '',
primaryKeys: primaryKeys[tableName].length > 1 ? '(' + pks + ')' : pks,
primaryKeysSelection: pks
Expand Down
4 changes: 1 addition & 3 deletions lib/dialects/postgres/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ Query.prototype.formatError = function (err) {
case '23505':
// there are multiple different formats of error messages for this error code
// this regex should check at least two
match = errDetail.replace(/"/g, '').match(/Key \((.*?)\)=\((.*?)\)/);

if (match) {
if (errDetail && (match = errDetail.replace(/"/g, '').match(/Key \((.*?)\)=\((.*?)\)/))) {
fields = _.zipObject(match[1].split(', '), match[2].split(', '));
errors = [];
message = 'Validation error';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"wkx": "0.2.0"
},
"devDependencies": {
"babel-core": "^6.2.0",
"babel-core": "^6.4.5",
"babel-preset-es2015": "^6.1.18",
"chai": "^3.0.0",
"chai-as-promised": "^5.1.0",
Expand Down
47 changes: 47 additions & 0 deletions test/integration/model/json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,53 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});

it('should be possible to destroy with where', function () {
var conditionSearch = {
where: {
data: {
employment : 'Hacker'
}
}
};

return Promise.join(
this.Event.create({
data: {
name: {
first: 'Elliot',
last: 'Alderson'
},
employment: 'Hacker'
}
}),
this.Event.create({
data: {
name: {
first: 'Christian',
last: 'Slater'
},
employment: 'Hacker'
}
}),
this.Event.create({
data: {
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);
});
});

});
}
});

0 comments on commit 9ad93d2

Please sign in to comment.