Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
flimzy opened this issue Apr 26, 2024 · 0 comments
Open

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

flimzy opened this issue Apr 26, 2024 · 0 comments

Comments

@flimzy
Copy link
Member

flimzy commented Apr 26, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant