diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2011-03-09 19:09:11 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2011-03-09 19:09:11 +0000 |
commit | 772fdde2eb970177438038a2479ec13385372cf5 (patch) | |
tree | f193e46bb51a99a533bdb13506c8e5fe248f0103 /src/couchdb/couch_httpd_db.erl | |
parent | 0d09aa9f79680be83e9893882bded0f4d8ba8b8d (diff) |
Merged revision 1079939 from trunk
Parameter "include_docs" now honors parameter "conflicts"
When querying a map view, /db/_all_docs/ or /db/_changes/ with
"include_docs=true", if "conflicts=true" is given as well, the
documents will contain the conflicts list (if there are conflicting
revisions).
Closes COUCHDB-549.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1079941 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_db.erl')
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 82e9b989..85c439ba 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -506,7 +506,7 @@ all_docs_view(Req, Db, Keys) -> FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, CurrentEtag, Db, UpdateSeq, TotalRowCount, #view_fold_helper_funs{ reduce_count = fun couch_db:enum_docs_reduce_to_count/1, - send_row = fun all_docs_send_json_view_row/5 + send_row = fun all_docs_send_json_view_row/6 }), AdapterFun = fun(#full_doc_info{id=Id}=FullDocInfo, Offset, Acc) -> case couch_doc:to_doc_info(FullDocInfo) of @@ -524,7 +524,7 @@ all_docs_view(Req, Db, Keys) -> FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, CurrentEtag, Db, UpdateSeq, TotalRowCount, #view_fold_helper_funs{ reduce_count = fun(Offset) -> Offset end, - send_row = fun all_docs_send_json_view_row/5 + send_row = fun all_docs_send_json_view_row/6 }), KeyFoldFun = case Dir of fwd -> @@ -551,21 +551,22 @@ all_docs_view(Req, Db, Keys) -> end end). -all_docs_send_json_view_row(Resp, Db, KV, IncludeDocs, RowFront) -> - JsonRow = all_docs_view_row_obj(Db, KV, IncludeDocs), +all_docs_send_json_view_row(Resp, Db, KV, IncludeDocs, Conflicts, RowFront) -> + JsonRow = all_docs_view_row_obj(Db, KV, IncludeDocs, Conflicts), send_chunk(Resp, RowFront ++ ?JSON_ENCODE(JsonRow)), {ok, ",\r\n"}. -all_docs_view_row_obj(_Db, {{DocId, error}, Value}, _IncludeDocs) -> +all_docs_view_row_obj(_Db, {{DocId, error}, Value}, _IncludeDocs, _Conflicts) -> {[{key, DocId}, {error, Value}]}; -all_docs_view_row_obj(Db, {_KeyDocId, DocInfo}, true) -> +all_docs_view_row_obj(Db, {_KeyDocId, DocInfo}, true, Conflicts) -> case DocInfo of #doc_info{revs = [#rev_info{deleted = true} | _]} -> {all_docs_row(DocInfo) ++ [{doc, null}]}; _ -> - {all_docs_row(DocInfo) ++ couch_httpd_view:doc_member(Db, DocInfo)} + {all_docs_row(DocInfo) ++ couch_httpd_view:doc_member( + Db, DocInfo, if Conflicts -> [conflicts]; true -> [] end)} end; -all_docs_view_row_obj(_Db, {_KeyDocId, DocInfo}, _IncludeDocs) -> +all_docs_view_row_obj(_Db, {_KeyDocId, DocInfo}, _IncludeDocs, _Conflicts) -> {all_docs_row(DocInfo)}. all_docs_row(#doc_info{id = Id, revs = [RevInfo | _]}) -> @@ -1221,6 +1222,8 @@ parse_changes_query(Req) -> Args#changes_args{timeout=list_to_integer(Value)}; {"include_docs", "true"} -> Args#changes_args{include_docs=true}; + {"conflicts", "true"} -> + Args#changes_args{conflicts=true}; {"filter", _} -> Args#changes_args{filter=Value}; _Else -> % unknown key value pair, ignore. |