-
Notifications
You must be signed in to change notification settings - Fork 7
GRDB Support #78
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
base: main
Are you sure you want to change the base?
GRDB Support #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool 🚀 I only have a few minor comments, the overal architecture for this looks great and I'm happy to see this integration added :)
| switch baseResult.blockResult { | ||
| case let success as PowerSyncResult.Success: | ||
| do { | ||
| let casted = try safeCast(success.value, to: ReturnType.self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is synchronous, is it possible to do something like var innerResult: ReturnType, assign to it in block and then return that value instead of casting here? That way we wouldn't have to cast to any and back.
Use resolvePowerSyncLoadableExtensionPath for GRDB integration. Fix WatchOS tests.
| #### Limitations | ||
|
|
||
| - Updating the PowerSync schema, with `updateSchema`, is not currently fully supported with GRDB connections. | ||
| - This integration requires currently statically linking PowerSync and GRDB. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - This integration requires currently statically linking PowerSync and GRDB. | |
| - This integration currently requires statically linking PowerSync and GRDB. |
Co-authored-by: benitav <benitav@users.noreply.github.com>
Overview
This builds off the amazing work of powersync-ja/powersync-kotlin#230. The linked PR adds support for creating a
PowerSyncDatabaseby supplying a customSQLiteConnectionPoolwhich manages SQLite connections.Some small additions and wip tests were added to the Kotlin implementation here
This PR adds Swift bindings to the Kotlin PR and then adds a
PowerSyncGRDBProduct to our SPM package. This product adapts a GRDB DatabasePool to aSQLiteConnectionPoolaccepted by the PowerSync SDK.This makes use of the fact that GRDB exposes the raw C SQLite pointer for it's connections. We then use this pointer with the newly introduced native
Databasekotlin implementation.The
PowerSyncGRDBproduct provides a means to generate a GRDBConfiguration. This configuration is used when creating the GRDBDatabasePool. We supply implementation for the configuration to load our PowerSync Rust core extension.APIs are still a WIP
Consumers can create a Pool with:
Consumers can then pass this pool when creating the PowerSyncDatabase.
Using the
DatabasePoolin the PowerSync SDK results in the same locking mechanisms being used between instances of thePowerSyncDatabaseandDatabasePool. Consumers should be safe to alternate between both clients.Demo
A new GRDB demo application has been added to the
demosfolder. This demo uses GRDB queries in Views.grdbdemo.mp4
TODOs:
Implement LeaseAll to lease all GRDB connections if possible