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

Result key order is now sorted by insertion time and not alphabetical #60

Merged
merged 3 commits into from
Nov 11, 2024

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.

cpp/JSIHelper.cpp Outdated Show resolved Hide resolved
@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