Skip to content

Commit 1866900

Browse files
authored
fix: input isn't defined in array case (#8890)
* fix: input isn't defined in array case * chore: provide test for array containing `null`
1 parent 9aaba0c commit 1866900

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/node_modules/pouchdb-find/src/validateSelector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var equalityOperators = [ '$eq', '$gt', '$gte', '$lt', '$lte' ];
9999
function validateSelector(input, isHttp) {
100100
if (Array.isArray(input)) {
101101
for (var entry of input) {
102-
if (typeof entry === 'object' && value !== null) {
102+
if (typeof entry === 'object' && entry !== null) {
103103
validateSelector(entry, isHttp);
104104
}
105105
}

tests/find/test-suite-1/test.eq.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,19 @@ describe('test.eq.js', function () {
457457
resp.docs.should.deep.equal([]);
458458
});
459459
});
460+
461+
it('does queries with array containing null', async () => {
462+
const db = context.db;
463+
464+
await db.put({ _id: '1', field: [null] });
465+
466+
const resp = await db.find({
467+
selector: { field: [null] }
468+
});
469+
470+
resp.docs.should.have.length(1);
471+
});
472+
460473
describe("implicit/explicit $eq", () => {
461474
it('implicit $eq queries against objects recurse', function () {
462475
var db = context.db;

0 commit comments

Comments
 (0)