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

Commit a32263f3 by Andrew Heuermann Committed by Erik Seliger

fix(redshift): allow standard_conforming_strings option (#10816)

We use sequelize with Redshift using the sequelize postgres dialect. It doesn't support the `standard_conforming_strings` option since it is based on an older version of postgres. Since https://github.com/sequelize/sequelize/commit/850c7fd04669e0fef9238b6dc4f8d6ee93ed71e9 was introduced, sequelize will try to set this option and fail, so I added a config option.

Co-authored-by: Simon Schick <demwizzy@gmail.com>
1 parent c9d3a978
...@@ -181,7 +181,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -181,7 +181,7 @@ class ConnectionManager extends AbstractConnectionManager {
// Disable escape characters in strings, see https://github.com/sequelize/sequelize/issues/3545 // Disable escape characters in strings, see https://github.com/sequelize/sequelize/issues/3545
let query = ''; let query = '';
if (connection['standard_conforming_strings'] !== 'on') { if (this.sequelize.options.standardConformingStrings !== false && connection['standard_conforming_strings'] !== 'on') {
// Disable escape characters in strings // Disable escape characters in strings
// see https://github.com/sequelize/sequelize/issues/3545 (security issue) // see https://github.com/sequelize/sequelize/issues/3545 (security issue)
// see https://www.postgresql.org/docs/current/static/runtime-config-compatible.html#GUC-STANDARD-CONFORMING-STRINGS // see https://www.postgresql.org/docs/current/static/runtime-config-compatible.html#GUC-STANDARD-CONFORMING-STRINGS
......
...@@ -75,7 +75,8 @@ class Sequelize { ...@@ -75,7 +75,8 @@ class Sequelize {
* @param {Object} [options.query={}] Default options for sequelize.query * @param {Object} [options.query={}] Default options for sequelize.query
* @param {Object} [options.set={}] Default options for sequelize.set * @param {Object} [options.set={}] Default options for sequelize.set
* @param {Object} [options.sync={}] Default options for sequelize.sync * @param {Object} [options.sync={}] Default options for sequelize.sync
* @param {String} [options.timezone='+00:00'] The timezone used when converting a date from the database into a JavaScript date. The timezone is also used to SET TIMEZONE when connecting to the server, to ensure that the result of NOW, CURRENT_TIMESTAMP and other time related functions have in the right timezone. For best cross platform performance use the format +/-HH:MM. Will also accept string versions of timezones used by moment.js (e.g. 'America/Los_Angeles'); this is useful to capture daylight savings time changes. * @param {string} [options.timezone='+00:00'] The timezone used when converting a date from the database into a JavaScript date. The timezone is also used to SET TIMEZONE when connecting to the server, to ensure that the result of NOW, CURRENT_TIMESTAMP and other time related functions have in the right timezone. For best cross platform performance use the format +/-HH:MM. Will also accept string versions of timezones used by moment.js (e.g. 'America/Los_Angeles'); this is useful to capture daylight savings time changes.
* @param {boolean} [options.standardConformingStrings=true] The PostgreSQL `standard_conforming_strings` session parameter. Set to `false` to not set the option. WARNING: Setting this to false may expose vulnerabilities and is not recommended!
* @param {Function} [options.logging=console.log] A function that gets executed every time Sequelize would log something. * @param {Function} [options.logging=console.log] A function that gets executed every time Sequelize would log something.
* @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging). * @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
* @param {Boolean} [options.omitNull=false] A flag that defines if null values should be passed to SQL queries or not. * @param {Boolean} [options.omitNull=false] A flag that defines if null values should be passed to SQL queries or not.
...@@ -155,6 +156,8 @@ class Sequelize { ...@@ -155,6 +156,8 @@ class Sequelize {
query: {}, query: {},
sync: {}, sync: {},
timezone: '+00:00', timezone: '+00:00',
standardConformingStrings: true,
// eslint-disable-next-line no-console
logging: console.log, logging: console.log,
omitNull: false, omitNull: false,
native: false, native: false,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!