apache / apache/pouchdb

PouchDB find error: selector containing `[null]` didn't work properly

Open
#8,901 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

```javascript

it("should not match", async () => {
const db = context.db;

await db.put({ _id: '1', field: "a" });

const resp = await db.find({
selector: { field: [null] }
});

resp.docs.should.have.length(0);
});
```

Response unexpectedly contain documents:
```console
AssertionError: expected [ Array(1) ] to have a length of 0 but got 1
```

With CouchDB 3.1.2 (same used in GH CI workflows):
```bash
# database connection
db=http://admin:password@localhost:5984/test

# write document
curl -s -H "Content-Type: application/json" -X PUT $db/1 -d '{"field":"a"}' | jq .

# query database
curl -s -H "Content-Type: application/json" -X POST $db/_find -d '{"selector":{ "field":[null] }}' | jq .
```
Output:
```console
{
"ok": true,
"id": "1",
"rev": "1-3430e46f86eeba0abfef2b577225476a"
}
{
"docs": [],
"bookmark": "nil",
"warning": "No matching index found, create an index to optimize query time."
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.