richard delorenzi created COUCHDB-2204:
------------------------------------------
Summary: rewrite of lists fail when not for key
Key: COUCHDB-2204
URL: https://issues.apache.org/jira/browse/COUCHDB-2204
Project: CouchDB
Issue Type: Bug
Security Level: public (Regular issues)
Components: HTTP Interface
Reporter: richard delorenzi
I have the following fragment in rewrite.json,
{{quote}}
{
"from": "server_lib/:~name",
"to": "_list/sub/design",
"query": {
"path": ["lib", ":~name" ],
"include_docs": "true"
}
},
{{quote}}
when I try to fetch the page with
{{quote}}
curl -s -D /dev/stderr -H "Accept: application/json"
'http://localhost:5984/q-couch-test/_design/couch-experiment/_rewrite/server_lib/myLib'
{{quote}}
I get this error
{{quote}}
log error:
[Tue, 18 Mar 2014 09:54:31 GMT] [info] [<0.5037.0>] Stacktrace:
[{erlang,iolist_to_binary,
[[<<"myLib">>,{[]}]],
[]},
{couch_httpd_rewrite,
'-maybe_encode_bindings/1-fun-0-',2,
[{file,"couch_httpd_rewrite.erl"},
{line,453}]},
{lists,foldl,3,
[{file,"lists.erl"},{line,1197}]},
{couch_httpd_rewrite,handle_rewrite_req,3,
[{file,"couch_httpd_rewrite.erl"},
{line,147}]},
{couch_httpd_db,do_db_req,2,
[{file,"couch_httpd_db.erl"},{line,230}]},
{couch_httpd,handle_request_int,5,
[{file,"couch_httpd.erl"},{line,317}]},
{mochiweb_http,headers,5,
[{file,"mochiweb_http.erl"},{line,136}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]
{{quote}}
The bug seems to be in couch_httpd_rewrite.erl in maybe_json. It treats keys
specially, so we can represent keys as lists but not other query strings.
e.g. this rewrite fragment works
{{quote}}
{
"from": "view/by_name/:~type",
"to": "_view/all-by-name",
"query": {
"startkey": [ ":~type", null ],
"endkey": [ ":~type", {} ]
}
},
{{quote}}
--
This message was sent by Atlassian JIRA
(v6.2#6252)