couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r951776 - in /couchdb/trunk: share/www/script/test/view_update_seq.js src/couchdb/couch_httpd_view.erl
Date Sat, 05 Jun 2010 21:59:54 GMT
Author: jchris
Date: Sat Jun  5 21:59:53 2010
New Revision: 951776

URL: http://svn.apache.org/viewvc?rev=951776&view=rev
Log:
update_seq is only in view response when update_seq=true is in query params

Modified:
    couchdb/trunk/share/www/script/test/view_update_seq.js
    couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: couchdb/trunk/share/www/script/test/view_update_seq.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_update_seq.js?rev=951776&r1=951775&r2=951776&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/view_update_seq.js (original)
+++ couchdb/trunk/share/www/script/test/view_update_seq.js Sat Jun  5 21:59:53 2010
@@ -11,7 +11,7 @@
 // the License.
 
 couchTests.view_update_seq = function(debug) {
-  var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
+  var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"true"});
   db.deleteDb();
   db.createDb();
   if (debug) debugger;
@@ -35,7 +35,7 @@ couchTests.view_update_seq = function(de
 
   T(db.info().update_seq == 1);
 
-  var resp = db.allDocs({});
+  var resp = db.allDocs({update_seq:true});
 
   T(resp.rows.length == 1);
   T(resp.update_seq == 1);
@@ -45,32 +45,40 @@ couchTests.view_update_seq = function(de
 
   resp = db.allDocs({limit: 1});
   T(resp.rows.length == 1);
+  T(!resp.update_seq, "all docs");
+
+  resp = db.allDocs({limit: 1, update_seq:true});
+  T(resp.rows.length == 1);
   T(resp.update_seq == 101);
 
-  resp = db.view('test/all_docs', {limit: 1});
+  resp = db.view('test/all_docs', {limit: 1, update_seq:true});
   T(resp.rows.length == 1);
   T(resp.update_seq == 101);
 
-  resp = db.view('test/summate', {});
+  resp = db.view('test/all_docs', {limit: 1, update_seq:false});
+  T(resp.rows.length == 1);
+  T(!resp.update_seq, "view");
+
+  resp = db.view('test/summate', {update_seq:true});
   T(resp.rows.length == 1);
   T(resp.update_seq == 101);
 
   db.save({"id":"0"});
-  resp = db.view('test/all_docs', {limit: 1,stale: "ok"});
+  resp = db.view('test/all_docs', {limit: 1,stale: "ok", update_seq:true});
   T(resp.rows.length == 1);
   T(resp.update_seq == 101);
 
-  resp = db.view('test/all_docs', {limit: 1});
+  resp = db.view('test/all_docs', {limit: 1, update_seq:true});
   T(resp.rows.length == 1);
   T(resp.update_seq == 102);
 
-  resp = db.view('test/all_docs',{},["0","1"]);
+  resp = db.view('test/all_docs',{update_seq:true},["0","1"]);
   T(resp.update_seq == 102);
 
-  resp = db.view('test/all_docs',{},["0","1"]);
+  resp = db.view('test/all_docs',{update_seq:true},["0","1"]);
   T(resp.update_seq == 102);
 
-  resp = db.view('test/summate',{group:true},["0","1"]);
+  resp = db.view('test/summate',{group:true, update_seq:true},["0","1"]);
   T(resp.update_seq == 102);
 
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=951776&r1=951775&r2=951776&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Sat Jun  5 21:59:53 2010
@@ -553,10 +553,17 @@ make_end_key_option(
 
 json_view_start_resp(Req, Etag, TotalViewCount, Offset, _Acc, UpdateSeq) ->
     {ok, Resp} = start_json_response(Req, 200, [{"Etag", Etag}]),
-    BeginBody = io_lib:format(
-            "{\"total_rows\":~w,\"update_seq\":~w,"
-            "\"offset\":~w,\"rows\":[\r\n",
-            [TotalViewCount, UpdateSeq, Offset]),
+    BeginBody = case couch_httpd:qs_value(Req, "update_seq") of
+    "true" ->
+        io_lib:format(
+                "{\"total_rows\":~w,\"update_seq\":~w,"
+                "\"offset\":~w,\"rows\":[\r\n",
+                [TotalViewCount, UpdateSeq, Offset]);
+    _Else ->
+        io_lib:format(
+                "{\"total_rows\":~w,\"offset\":~w,\"rows\":[\r\n",
+                [TotalViewCount, Offset])
+    end,
     {ok, Resp, BeginBody}.
 
 send_json_view_row(Resp, Db, {{Key, DocId}, Value}, IncludeDocs, RowFront) ->
@@ -566,7 +573,12 @@ send_json_view_row(Resp, Db, {{Key, DocI
 
 json_reduce_start_resp(Req, Etag, _Acc0, UpdateSeq) ->
     {ok, Resp} = start_json_response(Req, 200, [{"Etag", Etag}]),
-    {ok, Resp, io_lib:format("{\"update_seq\":~w,\"rows\":[\r\n",[UpdateSeq])}.
+    case couch_httpd:qs_value(Req, "update_seq") of
+    "true" ->
+        {ok, Resp, io_lib:format("{\"update_seq\":~w,\"rows\":[\r\n",[UpdateSeq])};
+    _Else ->
+        {ok, Resp, "{\"rows\":[\r\n"}
+    end.
 
 send_json_reduce_row(Resp, {Key, Value}, RowFront) ->
     send_chunk(Resp, RowFront ++ ?JSON_ENCODE({[{key, Key}, {value, Value}]})),



Mime
View raw message