diff --git a/lib/sql.js b/lib/sql.js index f83bd42..948afe1 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -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); }