apache / apache/couchdb

Key value doesn't work as json, only as string

Open
#5,396 3 comments 0 reactions 0 assignees View on GitHub
cant-reproduce
Dominant language
Erlang
Stars
7k
Forks
1.1k
Avg merge
1d 16h
Merged PRs (30d)
9

Description

[NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )

## Description

[NOTE]: # ( Describe the problem you're encountering. )
[TIP]: # ( Do NOT give us access or passwords to your actual CouchDB! )
When you pass "key" query to GET /{db}/_design/{ddoc}/_view/{view}
for example /your_db/_design/your_doc/_view/some_view?key="some_exist_key" works fine, it return rows if it match.
But if you use json as key: /your_db/_design/your_doc/_view/some_view?key={"json_example": "some_exist_key"} for example will not return any row even if {"json_example": "some_exist_key"} as key exist.
## Steps to Reproduce

[NOTE]: # ( Include commands to reproduce, if possible. curl is preferred. )
I use it

http://admin:admin@localhost:5984/account_documents/_design/unique_data_design_doc/_view/account_id_rev_by_hash_password_login?key={"login": "login_2","password_hash": "XKJyibT/PjDRPy2X/DP86v12ZmzKdHuVudId5E0+4ts"}

with view
```js
function (doc) {
emit({login:doc.login, password_hash:doc.password_hash}, [doc._id, doc._rev]);
}
```
If you want reproduce bag, just add document and then view with json as key and then try retrieve by then key row, you got empty row array

## Expected Behaviour
Possibility to retrieve document by json not only by string, so key like
```json
{"login": "login_2","password_hash": "XKJyibT/PjDRPy2X/DP86v12ZmzKdHuVudId5E0+4ts"}
```
will return not empty array rows if key is exists

[NOTE]: # ( Tell us what you expected to happen. )

## Your Environment
I think it's not matter
[TIP]: # ( Include as many relevant details about your environment as possible. )
[TIP]: # ( You can paste the output of curl http://YOUR-COUCHDB:5984/ here. )

* CouchDB version used: 3.4.2
* Browser name and version: edge, postman
* Operating system and version: windows 10

## Additional Context

[TIP]: # ( Add any other context about the problem here. )

Contributor guide

Open the contributing guide

Research direction

Start with the GET /{db}/_design/{ddoc}/_view/{view} request and compare how string and JSON key query values are parsed. Reproduce the supplied view and CouchDB 3.4.2 example, then add or adjust coverage for an object key; done when an existing emitted JSON key returns its row.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.