summaryrefslogtreecommitdiff
path: root/share/www
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2011-05-27 08:12:47 +0000
committerRobert Newson <rnewson@apache.org>2011-05-27 08:12:47 +0000
commit66fa2a431d1ff3e01ff026d7e2daf7dcb1eb21d1 (patch)
treed3cc8d40701abfbff28b2b873207348a4f667954 /share/www
parentd5aa8379b531c664bbad0a364fc19729f1e30315 (diff)
COUCHDB-1074 - fix variable substitution in rewriter
- key= ":key", startkey=[":a", ":b"] - variable substitution via query arguments - variable substituin via reversed path matching variables The variable substition is now a lot easier than the old one. Variables are decoded from the query if they are json, and we recode them only at the end. (Patch by BenoƮt Chesneau) git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1128189 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r--share/www/script/test/rewrite.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/share/www/script/test/rewrite.js b/share/www/script/test/rewrite.js
index 86905f8f..bb188773 100644
--- a/share/www/script/test/rewrite.js
+++ b/share/www/script/test/rewrite.js
@@ -119,6 +119,10 @@ couchTests.rewrite = function(debug) {
"query": {
"startkey": ":start",
"endkey": ":end"
+ },
+ "formats": {
+ "start": "int",
+ "end": "int"
}
},
{
@@ -164,6 +168,18 @@ couchTests.rewrite = function(debug) {
}
},
{
+ "from": "simpleForm/complexView7/:a/:b",
+ "to": "_view/complexView3",
+ "query": {
+ "key": [":a", ":b"],
+ "include_docs": ":doc"
+ },
+ "format": {
+ "doc": "bool"
+ }
+
+ },
+ {
"from": "/",
"to": "_view/basicView",
}
@@ -348,14 +364,14 @@ couchTests.rewrite = function(debug) {
T(!(/Key: 1/.test(xhr.responseText)));
T(/FirstKey: 3/.test(xhr.responseText));
T(/LastKey: 8/.test(xhr.responseText));
-
+
// get with query params
xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/simpleForm/basicViewPath/3/8");
T(xhr.status == 200, "with query params");
T(!(/Key: 1/.test(xhr.responseText)));
T(/FirstKey: 3/.test(xhr.responseText));
T(/LastKey: 8/.test(xhr.responseText));
-
+
// get with query params
xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/simpleForm/complexView");
T(xhr.status == 200, "with query params");
@@ -380,6 +396,11 @@ couchTests.rewrite = function(debug) {
xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/simpleForm/complexView6?a=test&b=essai");
T(xhr.status == 200, "with query params");
T(/Value: doc 4/.test(xhr.responseText));
+
+ xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_rewrite/simpleForm/complexView7/test/essai?doc=true");
+ T(xhr.status == 200, "with query params");
+ var result = JSON.parse(xhr.responseText);
+ T(typeof(result.rows[0].doc) === "object");
// test path relative to server
designDoc.rewrites.push({