couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r777757 - in /couchdb/trunk: share/www/script/test/ src/couchdb/
Date Sat, 23 May 2009 01:14:14 GMT
Author: jchris
Date: Sat May 23 01:14:13 2009
New Revision: 777757

URL: http://svn.apache.org/viewvc?rev=777757&view=rev
Log:
added an design doc option so that doc._local_seq can be available in the map view. Closes
COUCHDB-346

Modified:
    couchdb/trunk/share/www/script/test/basics.js
    couchdb/trunk/share/www/script/test/design_options.js
    couchdb/trunk/src/couchdb/couch_db.erl
    couchdb/trunk/src/couchdb/couch_doc.erl
    couchdb/trunk/src/couchdb/couch_httpd.erl
    couchdb/trunk/src/couchdb/couch_httpd_db.erl
    couchdb/trunk/src/couchdb/couch_view_updater.erl

Modified: couchdb/trunk/share/www/script/test/basics.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/basics.js?rev=777757&r1=777756&r2=777757&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/basics.js (original)
+++ couchdb/trunk/share/www/script/test/basics.js Sat May 23 01:14:13 2009
@@ -63,6 +63,12 @@
     var doc = db.open(id, {revs_info:true});
     T(doc._revs_info[0].status == "available");
 
+    // make sure you can do a seq=true option
+    var doc = db.open(id, {local_seq:true});
+    console.log(doc._local_seq)
+    T(doc._local_seq == 1);
+    
+
     // Create some more documents.
     // Notice the use of the ok member on the return result.
     T(db.save({_id:"1",a:2,b:4}).ok);

Modified: couchdb/trunk/share/www/script/test/design_options.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/design_options.js?rev=777757&r1=777756&r2=777757&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/design_options.js (original)
+++ couchdb/trunk/share/www/script/test/design_options.js Sat May 23 01:14:13 2009
@@ -18,16 +18,19 @@
 
   //// test the includes_design option
   var map = "function (doc) {emit(null, doc._id);}";
+  var withseq = "function(doc) {emit(doc._local_seq, null)}"
 
   // we need a design doc even to test temp views with it
   var designDoc = {
     _id:"_design/fu",
     language: "javascript",
     options: {
-      include_design: true        
+      include_design: true,
+      local_seq: true        
     },
     views: {
-      data: {"map": map}
+      data: {"map": map},
+      with_seq : {"map" : withseq}
     }
   };
   T(db.save(designDoc).ok);
@@ -60,4 +63,13 @@
   T(db.save(designDoc).ok);
   rows = db.view("bango/data").rows;
   T(rows.length == 0);
+  
+  // should also have local_seq in the view
+  var resp = db.save({});
+  rows = db.view("fu/with_seq").rows;
+  T(rows[0].key == 1)
+  T(rows[1].key == 2)
+  var doc = db.open(resp.id);
+  db.deleteDoc(doc);
+  console.log(resp)
 };

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=777757&r1=777756&r2=777757&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Sat May 23 01:14:13 2009
@@ -820,7 +820,7 @@
         {not_found, missing}
     end.
 
-doc_meta_info(#doc_info{revs=[#rev_info{rev=Rev}|RestInfo]}, RevTree, Options) ->
+doc_meta_info(#doc_info{high_seq=Seq,revs=[#rev_info{rev=Rev}|RestInfo]}, RevTree, Options)
->
     case lists:member(revs_info, Options) of
     false -> [];
     true ->
@@ -851,6 +851,10 @@
         [] -> [];
         DelConflictRevs -> [{deleted_conflicts, DelConflictRevs}]
         end
+    end ++
+    case lists:member(local_seq, Options) of
+    false -> [];
+    true -> [{local_seq, Seq}]
     end.
 
 

Modified: couchdb/trunk/src/couchdb/couch_doc.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_doc.erl?rev=777757&r1=777756&r2=777757&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_doc.erl Sat May 23 01:14:13 2009
@@ -56,6 +56,8 @@
                     {JsonObj, PosAcc - 1}
                 end, Start, RevsInfo),
             {<<"_revs_info">>, JsonRevsInfo};
+        ({local_seq, Seq}) ->
+            {<<"_local_seq">>, Seq};
         ({conflicts, Conflicts}) ->
             {<<"_conflicts">>, rev_to_strs(Conflicts)};
         ({deleted_conflicts, DConflicts}) ->

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=777757&r1=777756&r2=777757&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Sat May 23 01:14:13 2009
@@ -179,7 +179,7 @@
             send_error(HttpReq, Error);
         Tag:Error ->
             ?LOG_ERROR("Uncaught error in HTTP request: ~p",[{Tag, Error}]),
-            ?LOG_DEBUG("Stacktrace: ~p",[erlang:get_stacktrace()]),
+            ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
             send_error(HttpReq, Error)
     end,
 

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=777757&r1=777756&r2=777757&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Sat May 23 01:14:13 2009
@@ -801,6 +801,9 @@
         {"revs", "true"} ->
             Options = [revs | Args#doc_query_args.options],
             Args#doc_query_args{options=Options};
+        {"local_seq", "true"} ->
+            Options = [local_seq | Args#doc_query_args.options],
+            Args#doc_query_args{options=Options};
         {"revs_info", "true"} ->
             Options = [revs_info | Args#doc_query_args.options],
             Args#doc_query_args{options=Options};

Modified: couchdb/trunk/src/couchdb/couch_view_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view_updater.erl?rev=777757&r1=777756&r2=777757&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_view_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view_updater.erl Sat May 23 01:14:13 2009
@@ -97,11 +97,20 @@
     #doc_info{id=DocId, revs=[#rev_info{deleted=Deleted}|_]} = DocInfo,
     IncludeDesign = proplists:get_value(<<"include_design">>, 
         DesignOptions, false),
+    LocalSeq = proplists:get_value(<<"local_seq">>, 
+        DesignOptions, false),
+    DocOpts = case LocalSeq of
+        true ->
+            [conflicts, deleted_conflicts, local_seq];
+        _ ->
+            [conflicts, deleted_conflicts]
+    end,
+    ?LOG_ERROR("DocOpts ~p LocalSeq ~p",[DocOpts, LocalSeq]),
     case {IncludeDesign, DocId} of
     {_, GroupId} ->
         % uh oh. this is the design doc with our definitions. See if
         % anything in the definition changed.
-        case couch_db:open_doc_int(Db, DocInfo, [conflicts, deleted_conflicts]) of
+        case couch_db:open_doc_int(Db, DocInfo, DocOpts) of
         {ok, Doc} ->
             case couch_view_group:design_doc_to_view_group(Doc) of
             #group{sig=Sig} ->
@@ -126,7 +135,7 @@
             {Docs, [{DocId, []} | DocIdViewIdKeys]};
         true ->
             {ok, Doc} = couch_db:open_doc_int(Db, DocInfo, 
-                [conflicts, deleted_conflicts]),
+                DocOpts),
             {[Doc | Docs], DocIdViewIdKeys}
         end,
         



Mime
View raw message