diff --git a/lib/adapters/mysql.js b/lib/adapters/mysql.js index 5f66b195..d25d771a 100644 --- a/lib/adapters/mysql.js +++ b/lib/adapters/mysql.js @@ -104,7 +104,13 @@ MySQL.prototype.toDatabase = function (prop, val) { return this.toDatabase(prop, val[0]) + ' AND ' + this.toDatabase(prop, val[1]); - } + } else if (operator == 'inq' || operator == 'nin') { + if (!(val.propertyIsEnumerable('length')) && typeof val === 'object' && typeof val.length === 'number') { //if value is array + return val.join(','); + } else { + return val; + } + } } if (prop.type.name === 'Number') return val; if (prop.type.name === 'Date') { @@ -205,22 +211,31 @@ MySQL.prototype.all = function all(model, filter, callback) { var sqlCond = keyEscaped; switch (condType) { case 'gt': - sqlCond += ' > '; - break; + sqlCond += ' > '; + break; case 'gte': - sqlCond += ' >= '; - break; + sqlCond += ' >= '; + break; case 'lt': - sqlCond += ' < '; - break; + sqlCond += ' < '; + break; case 'lte': - sqlCond += ' <= '; - break; + sqlCond += ' <= '; + break; case 'between': - sqlCond += ' BETWEEN '; - break; + sqlCond += ' BETWEEN '; + break; + case 'inq': + sqlCond += ' IN '; + break; + case 'nin': + sqlCond += ' NOT IN '; + break; + case 'neq': + sqlCond + ' != '; + break; } - sqlCond += val; + sqlCond += (condType == 'inq' || condType == 'nin') ? '(' + val + ')' : val; cs.push(sqlCond); } else { cs.push(keyEscaped + ' = ' + val);