couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1128106 - in /couchdb/trunk: share/www/script/couch_tests.js share/www/script/test/regression.js src/couchdb/couch_db.erl
Date Thu, 26 May 2011 22:21:15 GMT
Author: rnewson
Date: Thu May 26 22:21:15 2011
New Revision: 1128106

URL: http://svn.apache.org/viewvc?rev=1128106&view=rev
Log:
COUCHDB-1178 - fix make_first_doc_on_disk function_clause error

Added:
    couchdb/trunk/share/www/script/test/regression.js
Modified:
    couchdb/trunk/share/www/script/couch_tests.js
    couchdb/trunk/src/couchdb/couch_db.erl

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=1128106&r1=1128105&r2=1128106&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Thu May 26 22:21:15 2011
@@ -75,6 +75,7 @@ loadTest("reduce.js");
 loadTest("reduce_builtin.js");
 loadTest("reduce_false.js");
 loadTest("reduce_false_temp.js");
+loadTest("regression.js");
 loadTest("replication.js");
 loadTest("replicator_db.js");
 loadTest("rev_stemming.js");

Added: couchdb/trunk/share/www/script/test/regression.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/regression.js?rev=1128106&view=auto
==============================================================================
--- couchdb/trunk/share/www/script/test/regression.js (added)
+++ couchdb/trunk/share/www/script/test/regression.js Thu May 26 22:21:15 2011
@@ -0,0 +1,48 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+couchTests.regression = function(debug) {
+    var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
+    db.deleteDb();
+    db.createDb();
+    if (debug) debugger;
+
+    // COUCHDB-1178
+    {
+        var r1 = {"_id":"doc","foo":"bar"};
+        var r2 = {"_id":"doc","foo":"baz","_rev":"1-4c6114c65e295552ab1019e2b046b10e"};
+        var r3 = {"_id":"doc","foo":"bam","_rev":"2-cfcd6781f13994bde69a1c3320bfdadb"};
+        var r4 = {"_id":"doc","foo":"bat","_rev":"3-cc2f3210d779aef595cd4738be0ef8ff"};
+
+        T(db.save({"_id":"_design/couchdb-1178","validate_doc_update":"function(){}"}).ok);
+        T(db.save(r1).ok);
+        T(db.save(r2).ok);
+        T(db.save(r3).ok);
+
+        T(db.compact().ok);
+        while (db.info().compact_running) {};
+
+        TEquals({"_id":"doc",
+                 "_rev":"3-cc2f3210d779aef595cd4738be0ef8ff",
+                 "foo":"bam",
+                 "_revisions":{"start":3,
+                               "ids":["cc2f3210d779aef595cd4738be0ef8ff",
+                                      "cfcd6781f13994bde69a1c3320bfdadb",
+                                      "4c6114c65e295552ab1019e2b046b10e"]}},
+                db.open("doc", {"revs": true}));
+
+        TEquals([], db.bulkSave([r4, r3, r2], {"new_edits":false}), "no failures");
+    }
+
+    // cleanup
+    db.deleteDb();
+};
\ No newline at end of file

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1128106&r1=1128105&r2=1128106&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Thu May 26 22:21:15 2011
@@ -767,6 +767,8 @@ update_docs(Db, Docs, Options, interacti
 % for the doc.
 make_first_doc_on_disk(_Db, _Id, _Pos, []) ->
     nil;
+make_first_doc_on_disk(Db, Id, Pos, [{_Rev, #doc{}} | RestPath]) ->
+    make_first_doc_on_disk(Db, Id, Pos-1, RestPath);
 make_first_doc_on_disk(Db, Id, Pos, [{_Rev, ?REV_MISSING}|RestPath]) ->
     make_first_doc_on_disk(Db, Id, Pos - 1, RestPath);
 make_first_doc_on_disk(Db, Id, Pos, [{_Rev, RevValue} |_]=DocPath) ->



Mime
View raw message