MCPcopy
hub / github.com/sequelize/sequelize / escape

Method escape

src/dialects/abstract/query-generator.js:1128–1158  ·  view source on GitHub ↗
(value, field, options)

Source from the content-addressed store, hash-verified

1126 @private
1127 */
1128 escape(value, field, options) {
1129 options = options || {};
1130
1131 if (value !== null && value !== undefined) {
1132 if (value instanceof Utils.SequelizeMethod) {
1133 return this.handleSequelizeMethod(value);
1134 }
1135 if (field && field.type) {
1136 if (field.type instanceof DataTypes.STRING
1137 && ['mysql', 'mariadb'].includes(this.dialect)
1138 && ['number', 'boolean'].includes(typeof value)) {
1139 value = String(Number(value));
1140 }
1141
1142 this.validate(value, field, options);
1143
1144 if (field.type.stringify) {
1145 // Users shouldn't have to worry about these args - just give them a function that takes a single arg
1146 const simpleEscape = escVal => SqlString.escape(escVal, this.options.timezone, this.dialect);
1147
1148 value = field.type.stringify(value, { escape: simpleEscape, field, timezone: this.options.timezone, operation: options.operation });
1149
1150 if (field.type.escape === false) {
1151 // The data-type already did the required escaping
1152 return value;
1153 }
1154 }
1155 }
1156 }
1157 return SqlString.escape(value, this.options.timezone, this.dialect);
1158 }
1159
1160 bindParam(bind) {
1161 return value => {

Callers 14

insertQueryMethod · 0.95
bulkInsertQueryMethod · 0.95
updateQueryMethod · 0.95
arithmeticQueryMethod · 0.95
getConstraintSnippetMethod · 0.95
escapeAttributesMethod · 0.95
addLimitAndOffsetMethod · 0.95
handleSequelizeMethodMethod · 0.95
whereItemQueryMethod · 0.95
getWhereConditionsMethod · 0.95

Calls 3

handleSequelizeMethodMethod · 0.95
validateMethod · 0.95
stringifyMethod · 0.65

Tested by

no test coverage detected