couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject View keys case-insensitive?
Date Thu, 09 Apr 2009 10:53:30 GMT
I was very surprised to find that view keys seem to be case-insensitive when
using startkey and endkey:

$ 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},    <<<< huh?!
{"id":"9","key":"aa","value":null}
]}

But not when fetching them individually:

$ curl -X POST -d '{"map":"function(doc) { emit(doc.foo, null); }"}' 'http://127.0.0.1:5984/test_suite_db/_temp_view?key="a"'
{"total_rows":26,"offset":7,"rows":[
{"id":"7","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?key="A"'
{"total_rows":26,"offset":8,"rows":[
{"id":"8","key":"A","value":null}
]}

(Ditto for startkey="a"&endkey="a", or startkey="A"&endkey="A")

At http://wiki.apache.org/couchdb/View_collation it says that view keys are
case-sensitive, which normally means that "A" does not appear in the range
"a" to "aa". And with normal ASCII ordering I would expect "A" to sort
before "a", as is the case with Javascript:

js> "a" < "A"
false

Could someone please explain to me what's going on? This may also explain my
recent report COUCHDB-324 where tilde does not collate where I'd expect.

I am running a recent SVN build:
{"couchdb":"Welcome","version":"0.9.0a762247"}

Thanks,

Brian.

Mime
View raw message