couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r814828 - in /couchdb/trunk: share/www/script/test/ src/couchdb/
Date Mon, 14 Sep 2009 20:20:50 GMT
Author: jchris
Date: Mon Sep 14 20:20:50 2009
New Revision: 814828

URL: http://svn.apache.org/viewvc?rev=814828&view=rev
Log:
finish committing my changes adventure. pardon the dust.

Modified:
    couchdb/trunk/share/www/script/test/all_docs.js
    couchdb/trunk/share/www/script/test/replication.js
    couchdb/trunk/share/www/script/test/view_include_docs.js
    couchdb/trunk/src/couchdb/couch_httpd_db.erl
    couchdb/trunk/src/couchdb/couch_httpd_view.erl
    couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl

Modified: couchdb/trunk/share/www/script/test/all_docs.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/all_docs.js?rev=814828&r1=814827&r2=814828&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/all_docs.js (original)
+++ couchdb/trunk/share/www/script/test/all_docs.js Mon Sep 14 20:20:50 2009
@@ -65,8 +65,7 @@
   // the deletion should make doc id 1 have the last seq num
   T(changes.results.length == 4);
   T(changes.results[3].id == "1");
-  // we've removed deletions from the changes feed as they are on the doc record not the
doc_info
-  T(!changes.results[3].deleted);
+  T(changes.results[3].deleted);
 
   // do an update
   var doc2 = db.open("3");

Modified: couchdb/trunk/share/www/script/test/replication.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/replication.js?rev=814828&r1=814827&r2=814828&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/replication.js (original)
+++ couchdb/trunk/share/www/script/test/replication.js Mon Sep 14 20:20:50 2009
@@ -100,12 +100,12 @@
         };
 
         this.afterAB1 = function(dbA, dbB) {
-          var rows = dbB.changes({include_docs:true}).results;
+          var rows = dbB.changes().results;
           var rowCnt = 0;
           for (var i=0; i < rows.length; i++) {
             if (rows[i].id == "del1") {
               rowCnt += 1;
-              T(rows[i].doc._deleted == true);
+              T(rows[i].deleted == true);
             }
           };
           T(rowCnt == 1);

Modified: couchdb/trunk/share/www/script/test/view_include_docs.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_include_docs.js?rev=814828&r1=814827&r2=814828&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/view_include_docs.js (original)
+++ couchdb/trunk/share/www/script/test/view_include_docs.js Mon Sep 14 20:20:50 2009
@@ -87,11 +87,13 @@
   // Check emitted _rev controls things
   resp = db.allDocs({include_docs: true}, ["0"]);
   var before = resp.rows[0].doc;
+
   var after = db.open("0");
-  after.integer = 100
+  after.integer = 100;
   after.prev = after._rev;
-  db.save(after);
-  after = db.open("0");
+  T(db.save(after).ok);
+  
+  var after = db.open("0");
   T(after._rev != after.prev);
   T(after.integer == 100);
 
@@ -111,6 +113,6 @@
   T(resp.rows[0].key == "0");
   T(resp.rows[0].id == "0");
   T(!resp.rows[0].doc);
-  T(resp.rows[0].error == "missing");
+  T(resp.rows[0].doc == null);
   T(resp.rows[1].doc.integer == 23);
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=814828&r1=814827&r2=814828&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Mon Sep 14 20:20:50 2009
@@ -74,11 +74,13 @@
 
 handle_changes_req(#httpd{method='GET',path_parts=[DbName|_]}=Req, Db) ->
     {FilterFun, EndFilterFun} = make_filter_funs(Req, Db),
+    {ok, Info} = couch_db:get_db_info(Db),
+    Seq = proplists:get_value(update_seq, Info),
     {Dir, StartSeq} = case couch_httpd:qs_value(Req, "descending", "false") of 
         "false" -> 
             {fwd, list_to_integer(couch_httpd:qs_value(Req, "since", "0"))}; 
         "true" -> 
-            {rev, 1000000000000000}; % super big value, should use current db seq
+            {rev, Seq};
         _Bad -> throw({bad_request, "descending must be true or false"})
     end,
     ResponseType = couch_httpd:qs_value(Req, "feed", "normal"),
@@ -104,7 +106,6 @@
             get_rest_db_updated() % clean out any remaining update messages
         end;
     true ->
-        {ok, Info} = couch_db:get_db_info(Db),
         CurrentEtag = couch_httpd:make_etag(Info),
         couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
             % send the etag
@@ -162,19 +163,19 @@
     end.
 
 changes_enumerator(DocInfos, {Db, _, _, FilterFun, Resp, "continuous", IncludeDocs}) ->
-    [#doc_info{id=Id, high_seq=Seq, revs=[#rev_info{rev=Rev}|_]}|_] = DocInfos,
+    [#doc_info{id=Id, high_seq=Seq, revs=[#rev_info{deleted=Del,rev=Rev}|_]}|_] = DocInfos,
     Results0 = [FilterFun(DocInfo) || DocInfo <- DocInfos],
     Results = [Result || Result <- Results0, Result /= null],
     case Results of
     [] ->
         {ok, {Db, Seq, nil, FilterFun, Resp, "continuous", IncludeDocs}};
     _ ->
-        send_chunk(Resp, [?JSON_ENCODE(changes_row(Db, Seq, Id, Results, Rev, IncludeDocs))
+        send_chunk(Resp, [?JSON_ENCODE(changes_row(Db, Seq, Id, Del, Results, Rev, IncludeDocs))
             |"\n"]),
         {ok, {Db, Seq, nil, FilterFun, Resp, "continuous", IncludeDocs}}
     end;
 changes_enumerator(DocInfos, {Db, _, Prepend, FilterFun, Resp, _, IncludeDocs}) ->
-    [#doc_info{id=Id, high_seq=Seq, revs=[#rev_info{rev=Rev}|_]}|_] = DocInfos,
+    [#doc_info{id=Id, high_seq=Seq, revs=[#rev_info{deleted=Del,rev=Rev}|_]}|_] = DocInfos,
     Results0 = [FilterFun(DocInfo) || DocInfo <- DocInfos],
     Results = [Result || Result <- Results0, Result /= null],
     case Results of
@@ -182,17 +183,18 @@
         {ok, {Db, Seq, Prepend, FilterFun, Resp, nil, IncludeDocs}};
     _ ->
         send_chunk(Resp, [Prepend, ?JSON_ENCODE(
-            changes_row(Db, Seq, Id, Results, Rev, IncludeDocs))]),
+            changes_row(Db, Seq, Id, Del, Results, Rev, IncludeDocs))]),
         {ok, {Db, Seq, <<",\n">>, FilterFun, Resp, nil, IncludeDocs}}
     end.
 
-changes_row(Db, Seq, Id, Results, Rev, true) ->
-    {[{seq,Seq},{id,Id},
-        {changes,Results}] ++
+changes_row(Db, Seq, Id, Del, Results, Rev, true) ->
+    {[{seq,Seq},{id,Id},{changes,Results}] ++ deleted_item(Del) ++
         couch_httpd_view:doc_member(Db, Id, Rev)};
-changes_row(_, Seq, Id, Results, _, false) ->
-    {[{seq,Seq},{id,Id},
-        {changes,Results}]}.
+changes_row(_, Seq, Id, Del, Results, _, false) ->
+    {[{seq,Seq},{id,Id},{changes,Results}] ++ deleted_item(Del)}.
+
+deleted_item(true) -> [{deleted,true}];
+deleted_item(_) -> [].
 
 send_changes(Req, Resp, Db, Dir, StartSeq, Prepend, ResponseType, FilterFun, End) ->
     Style = list_to_existing_atom(

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=814828&r1=814827&r2=814828&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Mon Sep 14 20:20:50 2009
@@ -603,7 +603,7 @@
             JsonDoc = couch_doc:to_json_obj(Doc, []),
             [{doc, JsonDoc}];
         _Else ->
-            [{error, missing}]
+            [{doc, null}]
     end.
     
 

Modified: couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl?rev=814828&r1=814827&r2=814828&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl Mon Sep 14 20:20:50 2009
@@ -277,9 +277,13 @@
 decode_row(<<",\n", Rest/binary>>) ->
     decode_row(Rest);
 decode_row(Row) ->
-    {[Seq, Id, {<<"changes">>,C}]} = ?JSON_DECODE(Row),
+    {Props} = ?JSON_DECODE(Row),
+    % [Seq, Id, {<<"changes">>,C}]
+    Seq = proplists:get_value(<<"seq">>, Props),
+    Id = proplists:get_value(<<"id">>, Props),
+    C = proplists:get_value(<<"changes">>, Props),
     C2 = [{[{<<"rev">>,couch_doc:parse_rev(R)}]} || {[{<<"rev">>,R}]}
<- C],
-    {[Seq, Id, {<<"changes">>,C2}]}.
+    {[{<<"seq">>, Seq}, {<<"id">>,Id}, {<<"changes">>,C2}]}.
 
 flush_updated_messages() ->
     receive updated -> flush_updated_messages()



Mime
View raw message