No title Revision 333339666130 (Tue Feb 22 2011 at 05:12) - Diff Link to this snippet: https://friendpaste.com/ZzyuR2gM0JVdDmgGhjXbI Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455diff --git a/src/couchdb/couch_httpd_rewrite.erl b/src/couchdb/couch_httpd_rewrite.erlindex 6c3d0e3..998f41f 100644--- a/src/couchdb/couch_httpd_rewrite.erl+++ b/src/couchdb/couch_httpd_rewrite.erl@@ -239,43 +239,17 @@ make_query_list([{Key, Value}|Rest], Bindings, Acc) when is_binary(Value) -> Value1 = replace_var(Key, Value, Bindings), make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]); make_query_list([{Key, Value}|Rest], Bindings, Acc) when is_list(Value) ->- Value1 = replace_var(Key, Value, Bindings),+ Value1 = to_json([replace_var(Key, V, Bindings) || V <- Value]), make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]); make_query_list([{Key, Value}|Rest], Bindings, Acc) -> make_query_list(Rest, Bindings, [{to_binding(Key), Value}|Acc]). -replace_var(Key, Value, Bindings) ->- case Value of- <<":", Var/binary>> ->- get_var(Var, Bindings, Value);- _ when is_list(Value) ->- Value1 = lists:foldr(fun(V, Acc) ->- V1 = case V of- <<":", VName/binary>> ->- case get_var(VName, Bindings, V) of- V2 when is_list(V2) ->- iolist_to_binary(V2);- V2 -> V2- end;- _ ->- - V- end,- [V1|Acc]- end, [], Value),- to_json(Value1);- _ when is_binary(Value) ->- Value;- _ ->- case Key of- <<"key">> -> to_json(Value);- <<"startkey">> -> to_json(Value);- <<"endkey">> -> to_json(Value);- _ ->- lists:flatten(?JSON_ENCODE(Value))- end- end.-+replace_var(_Key, <<":", Var/binary>> = Value, Bindings) ->+ get_var(Var, Bindings, Value);+replace_var(_Key, Value, _Bindings) when is_binary(Value) ->+ Value;+replace_var(_Key, Value, _Bindings) ->+ to_json(Value). get_var(VarName, Props, Default) -> VarName1 = to_binding(VarName),