diff --git a/lib/adapters/mongo/index.js b/lib/adapters/mongo/index.js index 0c54368d..0d61cde4 100644 --- a/lib/adapters/mongo/index.js +++ b/lib/adapters/mongo/index.js @@ -107,6 +107,7 @@ utils.mixin(Adapter.prototype, new (function () { // Case-insensitive equality via regex if (nocase) { val = val.toLowerCase(); + val = utils.string.escapeRegExpChars(val); re = new RegExp('^' + val + '$', 'i'); ret[comp.field] = re; } diff --git a/test/integration/adapters/shared.js b/test/integration/adapters/shared.js index 3ee07657..c95c22ae 100644 --- a/test/integration/adapters/shared.js +++ b/test/integration/adapters/shared.js @@ -174,6 +174,16 @@ tests = { }); } +, 'test all, by string with metacharacters equality': function (next) { + Zooby.all({foo: '.*'}, {nocase:true}, function (err, data) { + if (err) { + throw err; + } + assert.equal(0, data.length); + next(); + }); + } + , 'test all, by string case-insensitive bool': function (next) { Zooby.all({foo:'BAR'}, {nocase: true}, function (err, data) { if (err) {