summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2010-07-12 17:24:00 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2010-07-12 17:24:00 +0000
commit9599f7cd77ef8a6feacec3c8ead9432af02a57d3 (patch)
tree19902c436f7ef4dd3228999af969bd0899670805 /src
parentc5e6b0459adae4c9ef9386170993d7dd1b320cd0 (diff)
Reverting revision 963042 - lists:keystore/4 only replaces the first occurrence in the list.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963367 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_util.erl17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index 80c92271..2aa69af8 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -144,11 +144,18 @@ get_nested_json_value(Value, []) ->
get_nested_json_value(_NotJSONObj, _) ->
throw({not_found, json_mismatch}).
-proplist_apply_field({K, _V} = KV, L) ->
- lists:keystore(K, 1, L, KV).
-
-json_apply_field({K, _V} = KV, {L}) ->
- {lists:keystore(K, 1, L, KV)}.
+proplist_apply_field(H, L) ->
+ {R} = json_apply_field(H, {L}),
+ R.
+
+json_apply_field(H, {L}) ->
+ json_apply_field(H, L, []).
+json_apply_field({Key, NewValue}, [{Key, _OldVal} | Headers], Acc) ->
+ json_apply_field({Key, NewValue}, Headers, Acc);
+json_apply_field({Key, NewValue}, [{OtherKey, OtherVal} | Headers], Acc) ->
+ json_apply_field({Key, NewValue}, Headers, [{OtherKey, OtherVal} | Acc]);
+json_apply_field({Key, NewValue}, [], Acc) ->
+ {[{Key, NewValue}|Acc]}.
json_user_ctx(#db{name=DbName, user_ctx=Ctx}) ->
{[{<<"db">>, DbName},