Fix RegExp coercion

- Do not coerce RegExp literal/objects into a string
This commit is contained in:
Simon Ho 2015-07-28 02:02:59 -07:00
parent 7f76270940
commit 8d01d3e8e2
1 changed files with 5 additions and 0 deletions

View File

@ -712,6 +712,8 @@ SQLConnector.prototype.buildExpression = function(columnName, operator, columnVa
case 'nlike':
sqlExp += ' NOT LIKE ';
break;
// this case not needed since each database has its own regex syntax, but
// we leave the MySQL syntax here as a placeholder
case 'regexp':
sqlExp += ' REGEXP ';
break;
@ -797,6 +799,9 @@ SQLConnector.prototype._buildWhere = function(model, where) {
}
}
}
} else if (operator === 'regexp' && expression instanceof RegExp) {
// do not coerce RegExp based on property definitions
columnValue = expression;
} else {
columnValue = this.toColumnValue(props[key], expression);
}