summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2008-06-23 20:16:47 +0000
committerChristopher Lenz <cmlenz@apache.org>2008-06-23 20:16:47 +0000
commit46fec78939b70a8fbe0d1af85a25cf50db32622e (patch)
tree6b3e75a6939b4835723e7ef6ab24663dcd9d1bcf /share/www/script
parentd825d64a38dd7dbc17a8301258bdc36ad87797b3 (diff)
Improve error handling for undefined values emitted by map functions. Closes COUCHDB-83.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@670732 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/couch_tests.js34
1 files changed, 33 insertions, 1 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index e09569c2..e35dfa66 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -58,7 +58,7 @@ var tests = {
// create a map function that selects all documents whose "a" member
// has a value of 4, and then returns the document's b value.
var mapFunction = function(doc){
- if(doc.a==4)
+ if (doc.a==4)
emit(null, doc.b);
};
@@ -769,6 +769,38 @@ var tests = {
T(results.rows[0].value[0] == conflictRev);
},
+ view_errors: function(debug) {
+ var db = new CouchDB("test_suite_db");
+ db.deleteDb();
+ db.createDb();
+ if (debug) debugger;
+
+ var doc = {integer: 1, string: "1", array: [1, 2, 3]};
+ T(db.save(doc).ok);
+
+ // emitting a key value that is undefined should result in that row not
+ // being included in the view results
+ var results = db.query(function(doc) {
+ emit(doc.undef, null);
+ });
+ T(results.total_rows == 0);
+
+ // if a view function throws an exception, its results are not included in
+ // the view index, but the view does not itself raise an error
+ var results = db.query(function(doc) {
+ doc.undef(); // throws an error
+ });
+ T(results.total_rows == 0);
+
+ // if a view function includes an undefined value in the emitted key or
+ // value, an error is logged and the result is not included in the view
+ // index, and the view itself does not raise an error
+ var results = db.query(function(doc) {
+ emit([doc._id, doc.undef], null);
+ });
+ T(results.total_rows == 0);
+ },
+
view_pagination: function(debug) {
var db = new CouchDB("test_suite_db");
db.deleteDb();