Automattic / Automattic/mongo-query
Odd test - odd behavior
- Dominant language
- JavaScript
- Stars
- 65
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
In /test/filter.js line 172 the following test states
```
it('query subset narrow down', function(){
var ret = filter({
ferrets: [
{ name: 'tobi', age: 5 },
{ name: 'tobo', age: 4 },
{ name: 'tomas', age: 10 }
]
}, { 'ferrets.name': /^t/, 'ferrets.age': { $lt: 8 } });
expect(ret).to.eql({
ferrets: [
{ name: 'tobi', age: 5 },
{ name: 'tobo', age: 4 },
{ name: 'tomas', age: 10 }
]
});
});
```
I'd suspect tomas to be removed in the narrow down. But he isn't and your test passes. But why?
If changing { $lt: 8 } to { $gt: 8 }, I'd suspect tomas to be the only one remaining, but they all are. Why does changing the operator not make any difference? What am I misunderstanding here?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with test/filter.js at line 172 and run the test covering the query subset behavior. Compare the results for the $lt and $gt cases, then trace the filter behavior to determine whether the test expectation or implementation is inconsistent. Done means the operator behavior is explained and the relevant test or implementation reflects the intended semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100