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

Commit cebc3af8 by Keo Lin Committed by Felix Becker

fix(operators): $contains escaping (#7965)

Wrong escaping of text in array (' should escape as '', not \').

Closes #7950 
1 parent 4383922a
...@@ -41,7 +41,7 @@ function escape(val, timeZone, dialect, format) { ...@@ -41,7 +41,7 @@ function escape(val, timeZone, dialect, format) {
if (Array.isArray(val)) { if (Array.isArray(val)) {
const partialEscape = _.partial(escape, _, timeZone, dialect, format); const partialEscape = _.partial(escape, _, timeZone, dialect, format);
if (dialect === 'postgres' && !format) { if (dialect === 'postgres' && !format) {
return dataTypes.ARRAY.prototype.stringify(val, {escape}); return dataTypes.ARRAY.prototype.stringify(val, {escape: partialEscape});
} }
return val.map(partialEscape); return val.map(partialEscape);
} }
......
...@@ -414,6 +414,10 @@ if (dialect.match(/^postgres/)) { ...@@ -414,6 +414,10 @@ if (dialect.match(/^postgres/)) {
arguments: ['myTable', {where: { field: new Buffer('Sequelize')}}], arguments: ['myTable', {where: { field: new Buffer('Sequelize')}}],
expectation: "SELECT * FROM \"myTable\" WHERE \"myTable\".\"field\" = E'\\\\x53657175656c697a65';", expectation: "SELECT * FROM \"myTable\" WHERE \"myTable\".\"field\" = E'\\\\x53657175656c697a65';",
context: QueryGenerator context: QueryGenerator
}, {
title: 'string in array should escape \' as \'\'',
arguments: ['myTable', {where: { aliases: {$contains: ['Queen\'s']} }}],
expectation: "SELECT * FROM \"myTable\" WHERE \"myTable\".\"aliases\" @> ARRAY['Queen''s'];",
}, },
// Variants when quoteIdentifiers is false // Variants when quoteIdentifiers is false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!