couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r670653 - in /incubator/couchdb/trunk/share: server/main.js www/script/couch_tests.js
Date Mon, 23 Jun 2008 15:23:33 GMT
Author: cmlenz
Date: Mon Jun 23 08:23:32 2008
New Revision: 670653

URL: http://svn.apache.org/viewvc?rev=670653&view=rev
Log:
Seal the document in Javascript view functions in 'deep' mode so that it's not possible to
modify values in nested arrays and objects.

Modified:
    incubator/couchdb/trunk/share/server/main.js
    incubator/couchdb/trunk/share/www/script/couch_tests.js

Modified: incubator/couchdb/trunk/share/server/main.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/server/main.js?rev=670653&r1=670652&r2=670653&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/server/main.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/server/main.js [utf-8] Mon Jun 23 08:23:32 2008
@@ -74,7 +74,7 @@
         // ]
         //
         var doc = cmd[1];
-        seal(doc); // seal to prevent map functions from changing doc
+        seal(doc, true); // seal to prevent map functions from changing doc
         var buf = [];
         for (var i = 0; i < funs.length; i++) {
           map_results = [];

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=670653&r1=670652&r2=670653&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Mon Jun 23 08:23:32 2008
@@ -871,12 +871,18 @@
     db.createDb();
     if (debug) debugger;
 
-    var docs = makeDocs(1, 2);
-    T(db.bulkSave(docs).ok);
+    var doc = {integer: 1, string: "1", array: [1, 2, 3]};
+    T(db.save(doc).ok);
 
     // make sure that attempting to change the document throws an error
     var results = db.query(function(doc) {
-      doc._id = "foo";
+      doc.integer = 2;
+      emit(null, doc);
+    });
+    T(results.total_rows == 0);
+
+    var results = db.query(function(doc) {
+      doc.array[0] = 0;
       emit(null, doc);
     });
     T(results.total_rows == 0);



Mime
View raw message