Skip to content

Commit

Permalink
Merge 4440b09 into b824062
Browse files Browse the repository at this point in the history
  • Loading branch information
darkowic committed Jul 19, 2020
2 parents b824062 + 4440b09 commit ab952c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,10 @@ function getMultiFieldQueryOpts(selector, index) {
if (!matcher || !Object.keys(matcher).length) { // fewer fields in user query than in index
finish(i);
break;
} else if (Object.keys(matcher).some(isNonLogicalMatcher)) { // non-logical are ignored
finish(i);
break;
} else if (i > 0) {
if (Object.keys(matcher).some(isNonLogicalMatcher)) { // non-logical are ignored
finish(i);
break;
}
var usingGtlt = (
'$gt' in matcher || '$gte' in matcher ||
'$lt' in matcher || '$lte' in matcher);
Expand Down
26 changes: 26 additions & 0 deletions tests/find/test-suite-1/test.regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,31 @@ testCases.push(function (dbType, context) {
});
});

it('should works with index on multiple fields', function () {
var db = context.db;
var index = {
"index": {
"fields": ["name", "debut"]
}
};
return db.createIndex(index).then(function () {
return db.find({
selector: {
name: {$regex: "^Luig"},
debut: {$gt: 1980}
},
sort: ['name']
}).then(function (resp) {
var docs = resp.docs.map(function (doc) {
delete doc._rev;
return doc;
});

docs.should.deep.equal([
{ name: 'Luigi', rank: 11, _id: 'luigi', series: 'Mario', debut: 1983, awesome: false },
]);
});
});
});
});
});

0 comments on commit ab952c7

Please sign in to comment.