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

Commit 23952a2b by Michael Buckley

Fix bug in SqlString.escape which caused the function to be recursively called w…

…ith the wrong parameters when passed an array of strings. This would cause the incorrect escape algorithm to be used on the strings within the array when the dialect was set to postgres, sqlite, or mssql.
1 parent 04695d9f
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
- [ADDED] `validationFailed` hook [#1626](https://github.com/sequelize/sequelize/issues/1626) - [ADDED] `validationFailed` hook [#1626](https://github.com/sequelize/sequelize/issues/1626)
- [FIXED] Mark index as `unique: true` when `type: 'UNIQUE'`. Fixes [#5351](https://github.com/sequelize/sequelize/issues/5351) - [FIXED] Mark index as `unique: true` when `type: 'UNIQUE'`. Fixes [#5351](https://github.com/sequelize/sequelize/issues/5351)
- [ADDED[ Support for IEEE floating point literals in postgres and sqlite [#5194](https://github.com/sequelize/sequelize/issues/5194) - [ADDED[ Support for IEEE floating point literals in postgres and sqlite [#5194](https://github.com/sequelize/sequelize/issues/5194)
- [FIXED] Improper escaping of bound arrays of strings on Postgres, SQLite, and Microsoft SQL Server
# 3.19.3 # 3.19.3
- [FIXED] `updatedAt` and `createdAt` values are now set before validation [#5367](https://github.com/sequelize/sequelize/pull/5367) - [FIXED] `updatedAt` and `createdAt` values are now set before validation [#5367](https://github.com/sequelize/sequelize/pull/5367)
......
...@@ -48,7 +48,7 @@ SqlString.escape = function(val, timeZone, dialect, format) { ...@@ -48,7 +48,7 @@ SqlString.escape = function(val, timeZone, dialect, format) {
} }
if (Array.isArray(val)) { if (Array.isArray(val)) {
var escape = _.partialRight(SqlString.escape, timeZone, dialect); var escape = _.partial(SqlString.escape, _, timeZone, dialect, format);
if (dialect === 'postgres' && !format) { if (dialect === 'postgres' && !format) {
return dataTypes.ARRAY.prototype.stringify(val, {escape: escape}); return dataTypes.ARRAY.prototype.stringify(val, {escape: escape});
} }
......
...@@ -583,6 +583,15 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -583,6 +583,15 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
}); });
}); });
if (dialect === 'postgres' || dialect === 'sqlite' || dialect === 'mssql') {
it ('does not improperly escape arrays of strings bound to named parameters', function() {
var logSql;
return this.sequelize.query('select :stringArray as foo', { raw: true, replacements: { stringArray: [ '"string"' ] }, logging: function(s) { logSql = s; } }).then(function(result) {
expect(result[0]).to.deep.equal([{ foo: '"string"' }]);
});
});
}
it('throw an exception when binds passed with object and numeric $1 is also present', function() { it('throw an exception when binds passed with object and numeric $1 is also present', function() {
var self = this; var self = this;
var typeCast = (dialect === 'postgres') ? '::int' : ''; var typeCast = (dialect === 'postgres') ? '::int' : '';
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!