Skip to content

Conversation

Chriztiaan
Copy link
Contributor

@Chriztiaan Chriztiaan commented Nov 6, 2024

While testing react-native-quick-sqlite with a drizzle PoC, we found that RNQS sorts the keys in each row alphabetically instead of maintaining insertion order. This differs from web and OPsqlite and causes issues when depending on the order of Object.keys/Object.values.

This changeset changes the behaviour such that the metadata determines the order instead of the C++ map which causes the keys to be ordered alphabetically.

…aintain insertion order. The behaviour now matches other libraries.
@Chriztiaan Chriztiaan changed the title Fix/result key order Result key order is now sorted by insertion time and not alphabetical Nov 6, 2024
Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like there is some inefficiency in converting results from raw sqlite -> map<string, QuickValue> and then again to jsi::Object.

What about either:
1 Having the rows as vector<QuickValue> in the intermediate form (should have less overhead than the map, and you can pre-allocate each row vector with the correct size). OR:
2. Skip the intermediate value, and directly get each row as a jsi::Object.

It's only an optimization though - not sure how much of a difference this would make in practice. We can always leave that for later.

@Chriztiaan Chriztiaan marked this pull request as ready for review November 7, 2024 09:06
@Chriztiaan Chriztiaan merged commit 9ac4ce7 into main Nov 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants