You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Brian Candler (JIRA)" <ji...@apache.org> on 2009/04/09 12:29:12 UTC
[jira] Created: (COUCHDB-324) startkey and endkey don't work with ~
or %7E
startkey and endkey don't work with ~ or %7E
--------------------------------------------
Key: COUCHDB-324
URL: https://issues.apache.org/jira/browse/COUCHDB-324
Project: CouchDB
Issue Type: Bug
Environment: svn -r763553
Reporter: Brian Candler
The following range queries don't work as expected
startkey="a"&endkey="a~"
startkey="a"&endkey="a%7E"
(Aside: I was hoping to use "foo" to "foo~" as a reasonably clean way of querying "any key beginning with foo")
The following testcase shows this for "a~", since query doesn't encode it. However I wasn't sure how to test for "a%7E" cleanly.
--- /home/brian/svn/couchdb/share/www/script/test/view_collation.js 2009-03-20 12:50:46.000000000 +0000
+++ view_collation.js 2009-04-09 11:23:20.000000000 +0100
@@ -109,4 +109,11 @@
endkey : "b", endkey_docid: "b",
inclusive_end:false}).rows;
T(rows[rows.length-1].key == "aa")
+
+ // startkey and endkey with ~ (currently query doesn't encode this,
+ // but really we should test both a~ and a%7E)
+ var rows = db.query(queryFun, null, {startkey: "a", endkey: "a~"}).rows;
+ T(rows.length == 3); // a, A, aa
+ var rows = db.query(queryFun, null, {startkey: "a~", endkey: "b"}).rows;
+ T(rows.length == 1 && rows[0].key == "b");
};
Here are the actual results obtained using curl:
$ curl -X POST -d '{"map":"function(doc) { emit(doc.foo, null); }"}' 'http://127.0.0.1:5984/test_suite_db/_temp_view?startkey="a"&endkey="a~"'
{"total_rows":26,"offset":7,"rows":[
{"id":"7","key":"a","value":null},
{"id":"8","key":"A","value":null}
]}
$ curl -X POST -d '{"map":"function(doc) { emit(doc.foo, null); }"}' 'http://127.0.0.1:5984/test_suite_db/_temp_view?startkey="a"&endkey="a%7E"'
{"total_rows":26,"offset":7,"rows":[
{"id":"7","key":"a","value":null},
{"id":"8","key":"A","value":null}
]}
But what I was expecting was the same as range "a" to "az":
$ curl -X POST -d '{"map":"function(doc) { emit(doc.foo, null); }"}' 'http://127.0.0.1:5984/test_suite_db/_temp_view?startkey="a"&endkey="az"'
{"total_rows":26,"offset":7,"rows":[
{"id":"7","key":"a","value":null},
{"id":"8","key":"A","value":null},
{"id":"9","key":"aa","value":null}
]}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (COUCHDB-324) startkey and endkey don't work with
~ or %7E
Posted by "Brian Candler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/COUCHDB-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brian Candler resolved COUCHDB-324.
-----------------------------------
Resolution: Invalid
This is expected behaviour from the Unicode Collation Algorithm. I have added some notes on this to
http://wiki.apache.org/couchdb/View_collation
> startkey and endkey don't work with ~ or %7E
> --------------------------------------------
>
> Key: COUCHDB-324
> URL: https://issues.apache.org/jira/browse/COUCHDB-324
> Project: CouchDB
> Issue Type: Bug
> Environment: svn -r763553
> Reporter: Brian Candler
>
> The following range queries don't work as expected
> startkey="a"&endkey="a~"
> startkey="a"&endkey="a%7E"
> (Aside: I was hoping to use "foo" to "foo~" as a reasonably clean way of querying "any key beginning with foo")
> The following testcase shows this for "a~", since query doesn't encode it. However I wasn't sure how to test for "a%7E" cleanly.
> --- /home/brian/svn/couchdb/share/www/script/test/view_collation.js 2009-03-20 12:50:46.000000000 +0000
> +++ view_collation.js 2009-04-09 11:23:20.000000000 +0100
> @@ -109,4 +109,11 @@
> endkey : "b", endkey_docid: "b",
> inclusive_end:false}).rows;
> T(rows[rows.length-1].key == "aa")
> +
> + // startkey and endkey with ~ (currently query doesn't encode this,
> + // but really we should test both a~ and a%7E)
> + var rows = db.query(queryFun, null, {startkey: "a", endkey: "a~"}).rows;
> + T(rows.length == 3); // a, A, aa
> + var rows = db.query(queryFun, null, {startkey: "a~", endkey: "b"}).rows;
> + T(rows.length == 1 && rows[0].key == "b");
> };
> Here are the actual results obtained using curl:
> $ curl -X POST -d '{"map":"function(doc) { emit(doc.foo, null); }"}' 'http://127.0.0.1:5984/test_suite_db/_temp_view?startkey="a"&endkey="a~"'
> {"total_rows":26,"offset":7,"rows":[
> {"id":"7","key":"a","value":null},
> {"id":"8","key":"A","value":null}
> ]}
> $ curl -X POST -d '{"map":"function(doc) { emit(doc.foo, null); }"}' 'http://127.0.0.1:5984/test_suite_db/_temp_view?startkey="a"&endkey="a%7E"'
> {"total_rows":26,"offset":7,"rows":[
> {"id":"7","key":"a","value":null},
> {"id":"8","key":"A","value":null}
> ]}
> But what I was expecting was the same as range "a" to "az":
> $ curl -X POST -d '{"map":"function(doc) { emit(doc.foo, null); }"}' 'http://127.0.0.1:5984/test_suite_db/_temp_view?startkey="a"&endkey="az"'
> {"total_rows":26,"offset":7,"rows":[
> {"id":"7","key":"a","value":null},
> {"id":"8","key":"A","value":null},
> {"id":"9","key":"aa","value":null}
> ]}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.