sequelize
Advanced tools
Comparing version 6.25.2 to 6.25.3
"use strict"; | ||
class AbstractDialect { | ||
canBackslashEscape() { | ||
return false; | ||
} | ||
} | ||
@@ -58,3 +61,4 @@ AbstractDialect.prototype.supports = { | ||
JSON: false, | ||
deferrableConstraints: false | ||
deferrableConstraints: false, | ||
escapeStringConstants: false | ||
}; | ||
@@ -61,0 +65,0 @@ module.exports = AbstractDialect; |
@@ -20,2 +20,5 @@ "use strict"; | ||
} | ||
canBackslashEscape() { | ||
return true; | ||
} | ||
} | ||
@@ -22,0 +25,0 @@ MariadbDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), { |
@@ -20,2 +20,5 @@ "use strict"; | ||
} | ||
canBackslashEscape() { | ||
return true; | ||
} | ||
} | ||
@@ -22,0 +25,0 @@ MysqlDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), { |
@@ -20,2 +20,5 @@ "use strict"; | ||
} | ||
canBackslashEscape() { | ||
return !this.sequelize.options.standardConformingStrings; | ||
} | ||
} | ||
@@ -61,3 +64,4 @@ PostgresDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), { | ||
deferrableConstraints: true, | ||
searchPath: true | ||
searchPath: true, | ||
escapeStringConstants: true | ||
}); | ||
@@ -64,0 +68,0 @@ PostgresDialect.prototype.defaultVersion = "9.5.0"; |
@@ -47,2 +47,3 @@ var __create = Object.create; | ||
let isCommentBlock = false; | ||
let stringIsBackslashEscapable = false; | ||
for (let i = 0; i < sqlString.length; i++) { | ||
@@ -57,4 +58,5 @@ const char = sqlString[i]; | ||
if (isString) { | ||
if (char === "'" && !isBackslashEscaped(sqlString, i - 1)) { | ||
if (char === "'" && (!stringIsBackslashEscapable || !isBackslashEscaped(sqlString, i - 1))) { | ||
isString = false; | ||
stringIsBackslashEscapable = false; | ||
} | ||
@@ -93,2 +95,3 @@ continue; | ||
isString = true; | ||
stringIsBackslashEscapable = dialect.canBackslashEscape() || dialect.supports.escapeStringConstants && (sqlString[i - 1] === "E" || sqlString[i - 1] === "e") && canPrecedeNewToken(sqlString[i - 2]); | ||
continue; | ||
@@ -119,3 +122,3 @@ } | ||
const previousChar = sqlString[i - 1]; | ||
if (previousChar !== void 0 && !/[\s(,=[]/.test(previousChar)) { | ||
if (!canPrecedeNewToken(previousChar) && previousChar !== "[") { | ||
continue; | ||
@@ -141,3 +144,3 @@ } | ||
const previousChar = sqlString[i - 1]; | ||
if (previousChar !== void 0 && !/[\s(,=[]/.test(previousChar)) { | ||
if (!canPrecedeNewToken(previousChar) && previousChar !== "[") { | ||
continue; | ||
@@ -160,5 +163,12 @@ } | ||
} | ||
if (isString) { | ||
throw new Error(`The following SQL query includes an unterminated string literal: | ||
${sqlString}`); | ||
} | ||
output += sqlString.slice(previousSliceEnd, sqlString.length); | ||
return output; | ||
} | ||
function canPrecedeNewToken(char) { | ||
return char === void 0 || /[\s(>,=]/.test(char); | ||
} | ||
function isBackslashEscaped(string, pos) { | ||
@@ -165,0 +175,0 @@ let escaped = false; |
{ | ||
"name": "sequelize", | ||
"description": "Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.", | ||
"version": "6.25.2", | ||
"version": "6.25.3", | ||
"funding": [ | ||
@@ -6,0 +6,0 @@ { |
@@ -88,2 +88,3 @@ import type { Dialect } from '../../sequelize.js'; | ||
searchPath: boolean; | ||
escapeStringConstants: boolean; | ||
}; | ||
@@ -107,2 +108,3 @@ | ||
get supports(): DialectSupports; | ||
canBackslashEscape(): boolean; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2870755
32630