From 292091ece9a97c51f92e2dda547e732848db1515 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Thu, 19 Mar 2009 11:20:36 +0000 Subject: inclusive_end query option for views, defaults to true (does not change current behavior). inclusive_end=false treats endkey as an open interval. this is progress on COUCHDB-194. I think it is enough for 0.9, we can discuss switching the default behavior, and adding a similar option for startkey. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@755926 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/view_collation.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'share') diff --git a/share/www/script/test/view_collation.js b/share/www/script/test/view_collation.js index bcb63404..f59204c7 100644 --- a/share/www/script/test/view_collation.js +++ b/share/www/script/test/view_collation.js @@ -85,4 +85,28 @@ couchTests.view_collation = function(debug) { rows = db.query(queryFun, null, queryOptions).rows; T(rows.length == 1 && equals(rows[0].key, values[i])); } + + // test inclusive_end=true (the default) + // the inclusive_end=true functionality is limited to endkey currently + // if you need inclusive_start=false for startkey, please do implement. ;) + var rows = db.query(queryFun, null, {endkey : "b", inclusive_end:true}).rows; + T(rows[rows.length-1].key == "b") + // descending=true + var rows = db.query(queryFun, null, {endkey : "b", + descending:true, inclusive_end:true}).rows; + T(rows[rows.length-1].key == "b") + + // test inclusive_end=false + var rows = db.query(queryFun, null, {endkey : "b", inclusive_end:false}).rows; + T(rows[rows.length-1].key == "aa") + // descending=true + var rows = db.query(queryFun, null, {endkey : "b", + descending:true, inclusive_end:false}).rows; + T(rows[rows.length-1].key == "B") + + // inclusive_end=false overrides endkey_docid + var rows = db.query(queryFun, null, { + endkey : "b", endkey_docid: "b", + inclusive_end:false}).rows; + T(rows[rows.length-1].key == "aa") }; -- cgit v1.2.3