couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r799835 - in /couchdb/trunk: share/www/script/test/list_views.js src/couchdb/couch_httpd_show.erl src/couchdb/couch_query_servers.erl
Date Sat, 01 Aug 2009 11:16:36 GMT
Author: jan
Date: Sat Aug  1 11:16:36 2009
New Revision: 799835

URL: http://svn.apache.org/viewvc?rev=799835&view=rev
Log:
enable include_docs=true for list functions, patch by Mark Hammond, closes COUCHDB-444

Modified:
    couchdb/trunk/share/www/script/test/list_views.js
    couchdb/trunk/src/couchdb/couch_httpd_show.erl
    couchdb/trunk/src/couchdb/couch_query_servers.erl

Modified: couchdb/trunk/share/www/script/test/list_views.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/list_views.js?rev=799835&r1=799834&r2=799835&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/list_views.js (original)
+++ couchdb/trunk/share/www/script/test/list_views.js Sat Aug  1 11:16:36 2009
@@ -160,6 +160,12 @@
         var row = getRow();
         send(fooBarBam); // intentional error
         return "tail";
+      }),
+      docReference : stringFun(function(head, req) {
+        send("head");
+        var row = getRow();
+        send(row.doc.integer);
+        return "tail";
       })
     }
   };
@@ -316,6 +322,10 @@
   T(/ReferenceError/.test(xhr.responseText));
 
 
+  // with include_docs and a reference to the doc.
+  var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/docReference/basicView?include_docs=true");
+  T(xhr.responseText.match(/head0tail/));
+
   // now with extra qs params
   var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/qsParams/basicView?foo=blam");
   T(xhr.responseText.match(/blam/));

Modified: couchdb/trunk/src/couchdb/couch_httpd_show.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_show.erl?rev=799835&r1=799834&r2=799835&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_show.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_show.erl Sat Aug  1 11:16:36 2009
@@ -207,18 +207,18 @@
     {ok, Resp, ?b2l(?l2b(Chunks))}.
 
 make_map_send_row_fun(QueryServer) ->
-    fun(Resp, Db, Row, _IncludeDocs, RowFront) ->
-        send_list_row(Resp, QueryServer, Db, Row, RowFront)
+    fun(Resp, Db, Row, IncludeDocs, RowFront) ->
+        send_list_row(Resp, QueryServer, Db, Row, RowFront, IncludeDocs)
     end.
 
 make_reduce_send_row_fun(QueryServer, Db) ->
     fun(Resp, Row, RowFront) ->
-        send_list_row(Resp, QueryServer, Db, Row, RowFront)
+        send_list_row(Resp, QueryServer, Db, Row, RowFront, false)
     end.
 
-send_list_row(Resp, QueryServer, Db, Row, RowFront) ->
+send_list_row(Resp, QueryServer, Db, Row, RowFront, IncludeDoc) ->
     try
-        [Go,Chunks] = couch_query_servers:render_list_row(QueryServer, Db, Row),
+        [Go,Chunks] = couch_query_servers:render_list_row(QueryServer, Db, Row, IncludeDoc),
         Chunk = RowFront ++ ?b2l(?l2b(Chunks)),
         send_non_empty_chunk(Resp, Chunk),
         case Go of

Modified: couchdb/trunk/src/couchdb/couch_query_servers.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_query_servers.erl?rev=799835&r1=799834&r2=799835&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_query_servers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_query_servers.erl Sat Aug  1 11:16:36 2009
@@ -19,7 +19,7 @@
 -export([start_doc_map/2, map_docs/2, stop_doc_map/1]).
 -export([reduce/3, rereduce/3,validate_doc_update/5]).
 -export([render_doc_show/6, start_view_list/2,
-        render_list_head/4, render_list_row/3, render_list_tail/1]).
+        render_list_head/4, render_list_row/4, render_list_tail/1]).
 -export([start_filter/2, filter_doc/4, end_filter/1]).
 % -export([test/0]).
 
@@ -199,11 +199,11 @@
     JsonReq = couch_httpd_external:json_req_obj(Req, Db),
     couch_os_process:prompt(Pid, [<<"list">>, Head, JsonReq]).
 
-render_list_row({_Lang, Pid}, Db, {{Key, DocId}, Value}) ->
-    JsonRow = couch_httpd_view:view_row_obj(Db, {{Key, DocId}, Value}, false),
+render_list_row({_Lang, Pid}, Db, {{Key, DocId}, Value}, IncludeDoc) ->
+    JsonRow = couch_httpd_view:view_row_obj(Db, {{Key, DocId}, Value}, IncludeDoc),
     couch_os_process:prompt(Pid, [<<"list_row">>, JsonRow]);
 
-render_list_row({_Lang, Pid}, _, {Key, Value}) ->
+render_list_row({_Lang, Pid}, _, {Key, Value}, _IncludeDoc) ->
     JsonRow = {[{key, Key}, {value, Value}]},
     couch_os_process:prompt(Pid, [<<"list_row">>, JsonRow]).
 



Mime
View raw message