Skip to content

x/sqlite: object key order is not preserved in indexes #952

@flimzy

Description

@flimzy

The CouchDB documentation specifies that:

{b:2, a:1} // Member order does matter for collation.
// CouchDB preserves member order
// but doesn't require that clients will.
// this test might fail if used with a js engine
// that doesn't preserve order

We don't honor this, becuase Go maps are not ordered.

In principle, we may be able to work around this limitation, but it's non-trivial. A first attempt was to pass raw JSON to the JS function, then call JSON.parse, but as documented, goja's JSON.parse uses the underlying Go encoding/json package, which does not preserve order. So the work-around probably involves passing a custom data type to the goja runtime, which is then, in JS space, converted to a standard JS object, before being passed to the map and reduce functions. This is likely complex, and will hurt performance. So I prefer not to do it, unless this proves a difficult problem for users.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions