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

Method escape

lib/dialects/abstract/query-generator.js:1011–1035  ·  view source on GitHub ↗
(value, field, options)

Source from the content-addressed store, hash-verified

1009 @private
1010 */
1011 escape(value, field, options) {
1012 options = options || {};
1013
1014 if (value !== null && value !== undefined) {
1015 if (value instanceof Utils.SequelizeMethod) {
1016 return this.handleSequelizeMethod(value);
1017 }
1018 if (field && field.type) {
1019 this.validate(value, field, options);
1020
1021 if (field.type.stringify) {
1022 // Users shouldn't have to worry about these args - just give them a function that takes a single arg
1023 const simpleEscape = escVal => SqlString.escape(escVal, this.options.timezone, this.dialect);
1024
1025 value = field.type.stringify(value, { escape: simpleEscape, field, timezone: this.options.timezone, operation: options.operation });
1026
1027 if (field.type.escape === false) {
1028 // The data-type already did the required escaping
1029 return value;
1030 }
1031 }
1032 }
1033 }
1034 return SqlString.escape(value, this.options.timezone, this.dialect);
1035 }
1036
1037 bindParam(bind) {
1038 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