ENGAGE-383: CouchDB appears to require that properties are listed in a specific order when specifying a composite key for a Couch view

Metadata

Source
ENGAGE-383
Type
Bug
Priority
Major
Status
Closed
Resolution
Won't Fix
Assignee
N/A
Reporter
Colin Clark
Created
2010-02-12T15:54:05.000-0500
Updated
2010-02-12T17:07:46.000-0500
Versions
  1. 0.3b
Fixed Versions
N/A
Component
  1. Catalogue

Description

CouchDB appears to have a very strange bug. When using a composite key to a view, for example:

{
key1: "foo",
key2: "bar"
}

You must ensure that the keys are listed in the same order as they were defined in the view, otherwise Couch will fail to match them. Since JavaScript objects don't specify a fixed order for keys (how could they?), this must be a bug in Couch itself.

If I were to speculate, perhaps Couch is comparing the stringified version of keys.

Comments

  • Colin Clark commented 2010-02-12T17:07:46.000-0500

    This is known behaviour in Couch DB, as outlined in this document on how view collation works:

    http://wiki.apache.org/couchdb/View_collation

    It does raise the distinct possibility that, when deployed on a different VM, we'll have problems with JSON serialization and Couch Views. Time to write our own Couch-specific JSON serializer.