You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/08/30 04:18:03 UTC

[GitHub] [couchdb] harish1992 commented on issue #2144: Using `+` in a document `_id`

harish1992 commented on issue #2144: Using `+` in a document `_id`
URL: https://github.com/apache/couchdb/issues/2144#issuecomment-526449372
 
 
   So I tried the document creation again by replacing `id` with `_id`:
   
   `curl -H 'Content-Type: application/json' -X POST http://127.0.0.1:5984/kitura_test_db -d '{"_id": "123+456","key": "123+456"}'`
   
   Response:
   
   `{"ok":true,"id":"123+456","rev":"3-70ff850521574a05877483e9828dc65c"}`
   
   So the document gets successfully created. But the catch here is , I am unable to retrieve the document using `_id`.
    
   The request `curl http://127.0.0.1:5984/kitura_test_db/123+456`  yields the response
   
   `{"error":"not_found","reason":"missing"}` 
   
   But the request:
   `curl http://127.0.0.1:5984/kitura_test_db/_all_docs`  results in
   
   `{"total_rows":2,"offset":0,"rows":[
   {"id":"123+456","key":"123+456","value":{"rev":"3-70ff850521574a05877483e9828dc65c"}},
   {"id":"123456","key":"123456","value":{"rev":"3-aceebea5ce5cc3aaa33ff520e1ee40dc"}}
   ]}`
   
   As you can see the document with `_id` `123+456` is still present, but I am unable to retrieve it like other docs  with no `+` in their ids  unless I percent encode `+` like this:
   
   `curl http://127.0.0.1:5984/kitura_test_db/123%2B456` 
   
   Response:
   
   `{"_id":"123+456","_rev":"3-70ff850521574a05877483e9828dc65c","key":"123+456"}`
   
   Why does the CouchDB agent allow the document creation with `+` sign but require percent encoding of  `+` sign for retrieval? 
   
   ### Steps to reproduce the issue
   
   Step 1: create a doc with `_id` `123+456` 
   
     `curl -H 'Content-Type: application/json' -X POST http://127.0.0.1:5984/kitura_test_db -d '{"_id": "123+456","key": "123+456"}'`
   
   Step 2: Retrieve the doc
   
   `curl http://127.0.0.1:5984/kitura_test_db/123+456`
   
   ### Expected behaviour
   
   if `_id` with `+` sign is valid then all the DB operations must be possible on document not just creation
   
   
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services