Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Fixed
-
None
Description
In CouchDB 1.X, specifying raw collation in a view definition changes the result order:
$ curl http://localhost:5984/nullsort -XPUT {"ok":true} $ curl http://localhost:5984/nullsort/_bulk_docs -XPOST -H'Content-Type:application/json' -d '{"docs":[{"test":1},{"test":null}]}' [{"ok":true,"id":"a9f86d3c33d25c15de6eca8578001d98","rev":"1-ea7a185b492abc69a6c8e0358d244a98"},{"ok":true,"id":"a9f86d3c33d25c15de6eca8578002c25","rev":"1-9b2a5b981a9dd0ad1b3a3e826498e9bb"}] $ curl http://localhost:5984/nullsort -XPOST -H'Content-Type:application/json' -d '{"_id": "_design/test","views":{"nullsort":{"map": "function (doc) {emit(doc.test, 1);}","options":{"collation": "raw"}}}}' {"ok":true,"id":"_design/test","rev":"1-2df3ab52426a7138b6898791024595d0"} $ curl http://localhost:5984/nullsort/_design/test/_view/nullsort {"total_rows":2,"offset":0,"rows":[ {"id":"a9f86d3c33d25c15de6eca8578001d98","key":1,"value":1}, {"id":"a9f86d3c33d25c15de6eca8578002c25","key":null,"value":1} ]}
In CouchDB 2.0, with n=1, q=4:
$ curl http://localhost:15984/nullsort -XPUT {"ok":true} $ curl http://localhost:15984/nullsort/_bulk_docs -XPOST -H'Content-Type:application/json' -d '{"docs":[{"test":1},{"test":null}]}' [{"ok":true,"id":"51cf4c5a56f86f524b0e36f52800029d","rev":"1-ea7a185b492abc69a6c8e0358d244a98"},{"ok":true,"id":"51cf4c5a56f86f524b0e36f528000d9c","rev":"1-9b2a5b981a9dd0ad1b3a3e826498e9bb"}] $ curl http://localhost:15984/nullsort -XPOST -H'Content-Type:application/json' -d '{"_id": "_design/test","views":{"nullsort":{"map": "function (doc) {emit(doc.test, 1);}","options":{"collation": "raw"}}}}' {"ok":true,"id":"_design/test","rev":"1-2df3ab52426a7138b6898791024595d0"} $ curl http://localhost:15984/nullsort/_design/test/_view/nullsort {"total_rows":2,"offset":0,"rows":[ {"id":"51cf4c5a56f86f524b0e36f528000d9c","key":null,"value":1}, {"id":"51cf4c5a56f86f524b0e36f52800029d","key":1,"value":1} ]}
Note that null is returned before 1.
If q=1, the ordering matches CouchDB 1.X
Attachments
Issue Links
- incorporates
-
COUCHDB-2932 View query crashes if the emited key contains hidden characters
- Resolved