(value, field, options)
| 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 => { |
no test coverage detected