OP-Engineering / op-sqlite

Fastest SQLite library for react-native by @ospfranco
MIT License
598 stars 41 forks source link

Bug: When using `libsql` and the `openSync` method, the embedded replica (local database) will not sync with the remote database #124

Closed theorib closed 4 months ago

theorib commented 4 months ago

Describe the bug: When using op-sqlite with libsql (and Turso), the openSync method does not sync the Embedded Replica (local database) with the remote database. This renders the embedded replica unusable.

A few more things affect the implementation and usage of openSync to effectively use embedded replicas with op-sqlite:

I would happily open a PR but I'm not versed in C++ , I'm more than happy to help debug and test.

Versions:

Reproducible example Clone the GitHub repo and follow the instructions outlined on the README.md file to get the a sample database running with Turso: https://github.com/theorib/op-sqlite-turso-expo-react-native.git

ospfranco commented 4 months ago

I don't see any way to pass a sync interval in the C headers so I don't think it is possible. However I just opened a PR that enables the sync call so you can replicate a sync interval in pure JS easily.

ospfranco commented 4 months ago

Released in version 6.2.11

theorib commented 4 months ago

It looks like the latest commit on libsql's repo exposes the sync_interval property on the C Bindings via libsql_open_sync_with_config.

ospfranco commented 4 months ago

Released in 7.0.1