You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/12/04 21:09:37 UTC

[06/22] couch commit: updated refs/heads/2491-refactor-couch-httpd-auth to 3e8286d

Make include_docs=true work for view changes


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/20cd47e7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/20cd47e7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/20cd47e7

Branch: refs/heads/2491-refactor-couch-httpd-auth
Commit: 20cd47e7164975618b32084a10774e4f8103e608
Parents: 8d5c900
Author: Benjamin Bastian <be...@gmail.com>
Authored: Tue Aug 26 15:55:07 2014 +0700
Committer: Benjamin Bastian <be...@gmail.com>
Committed: Fri Oct 31 12:43:53 2014 -0700

----------------------------------------------------------------------
 src/couch_changes.erl | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/20cd47e7/src/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_changes.erl b/src/couch_changes.erl
index 8ff109b..29920da 100644
--- a/src/couch_changes.erl
+++ b/src/couch_changes.erl
@@ -643,9 +643,9 @@ changes_enumerator(Value0, Acc) ->
 
 changes_row(Results, DocInfo, #changes_acc{filter={fast_view,_,_,_}}=Acc) ->
     format_doc_info_change(Results, DocInfo, Acc);
-changes_row(Results, KV, #changes_acc{view=#mrview{}}) ->
-    {{Seq, Key}, {Id, Value, _Rev}} = KV,
-    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"key">>, Key}, {<<"value">>, Value}, {<<"changes">>, Results}]};
+changes_row(Results, KV, #changes_acc{view=#mrview{}}=Acc) ->
+    {{Seq, Key}, {Id, Value, Rev}} = KV,
+    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"key">>, Key}, {<<"value">>, Value}, {<<"changes">>, Results}] ++ maybe_get_changes_doc({Id, Rev}, Acc)};
 changes_row(Results, #doc_info{}=DocInfo, Acc) ->
     format_doc_info_change(Results, DocInfo, Acc).
 
@@ -653,29 +653,35 @@ format_doc_info_change(Results, #doc_info{}=DocInfo, Acc) ->
     #doc_info{
         id = Id, high_seq = Seq, revs = [#rev_info{deleted = Del} | _]
     } = DocInfo,
+    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>, Results}] ++
+        deleted_item(Del) ++ maybe_get_changes_doc(DocInfo, Acc)}.
+
+maybe_get_changes_doc(Value, #changes_acc{include_docs=true}=Acc) ->
     #changes_acc{
         db = Db,
         include_docs = IncDoc,
         doc_options = DocOpts,
         conflicts = Conflicts
     } = Acc,
-    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>, Results}] ++
-        deleted_item(Del) ++ case IncDoc of
-            true ->
-                Opts = case Conflicts of
-                    true -> [deleted, conflicts];
-                    false -> [deleted]
-                end,
-                Doc = couch_index_util:load_doc(Db, DocInfo, Opts),
-                case Doc of
-                    null ->
-                        [{doc, null}];
-                    _ ->
-                        [{doc, couch_doc:to_json_obj(Doc, DocOpts)}]
-                end;
-            false ->
-                []
-        end}.
+    case IncDoc of
+        true ->
+            Opts = case Conflicts of
+                true -> [deleted, conflicts];
+                false -> [deleted]
+            end,
+            Doc = couch_index_util:load_doc(Db, Value, Opts),
+            case Doc of
+                null ->
+                    [{doc, null}];
+                _ ->
+                    [{doc, couch_doc:to_json_obj(Doc, DocOpts)}]
+            end;
+        false ->
+            []
+    end;
+maybe_get_changes_doc(_Value, _Acc) ->
+    [].
+
 
 deleted_item(true) -> [{<<"deleted">>, true}];
 deleted_item(_) -> [].