Hi everybody,

please take a look at the following transcript. It creates a database, inserts 
some documents and queries them. My issue is the sorting of _all_docs vs the 
result of the view: In the first case, hello leads, while in the second case 
Hello comes first:

$ curl http://localhost:5984/
{"couchdb":"Welcome","uuid":"a96430b1b7736a09cf6433604a030bd2","version":"1.6.1","vendor":{"name":"The
 Apache Software Foundation","version":"1.6.1"}}
$ curl -X PUT http://localhost:5984/test-ids
{"ok":true}
$ curl -X POST http://localhost:5984/test-ids/_bulk_docs 
-HContent-type:application/json -d'{"docs": [{"_id": "Hello"}, {"_id": 
"hello"}, {"_id": "_design/tst", "views": {"ids": {"map":"function (doc) { 
emit(doc._id, 1); }"}}}]}'
[{"ok":true,"id":"Hello","rev":"1-967a00dff5e02add41819138abb3284d"},{"ok":true,"id":"hello","rev":"1-967a00dff5e02add41819138abb3284d"},
{"ok":true,"id":"_design/tst","rev":"1-e267a159c1b990605f05150480ccc754"}]
$ curl http://localhost:5984/test-ids/_all_docs
{"total_rows":3,"offset":0,"rows":[
{"id":"Hello","key":"Hello","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
{"id":"_design/tst","key":"_design/tst","value":{"rev":"1-e267a159c1b990605f05150480ccc754"}},
{"id":"hello","key":"hello","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}
]}
$ curl http://localhost:5984/test-ids/_design/tst/_view/ids
{"total_rows":2,"offset":0,"rows":[
{"id":"hello","key":"hello","value":1},
{"id":"Hello","key":"Hello","value":1}
]}
$

When I do the same in PouchDB, the results are different (but consistent):

var db = new PouchDB('test-ids');
db.replicate.from('http://localhost:5984/test-ids')
.then(function () { return db.allDocs(); })
.then(function (docs) { console.log(JSON.stringify(docs.rows)); return 
db.query('tst/ids'); })
.then(function (docs) { console.log(JSON.stringify(docs.rows)); })gives

[{"id":"Hello","key":"Hello","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},{"id":"_design/tst",.....},{"id":"hello","key":"hello","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}]
[{"key":"Hello","id":"Hello","value":1},{"key":"hello","id":"hello","value":1}]

Is this behaviour a bug or a feature? The documentation for views says:

* Text (case sensitive, lowercase first)Best regards,
Jonas Weber

Reply via email to