-
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
Open
stevensJourney
wants to merge
63
commits into
main
Choose a base branch
from
grdb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
GRDB Support #78
Changes from 2 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
245e3d2
wip: grdb connection pool
stevensJourney 8428135
wip: grdb
stevensJourney dbd9c09
Use latest GRDB package. Update tests and queries.
stevensJourney 6f32934
wip: table update hooks
stevensJourney e2681f6
Add test for GRDB updates triggered by GRDB
stevensJourney a79ec5c
add join test
stevensJourney 8a278a1
WIP: Add GRDB demo app
stevensJourney 4002d85
demo improvements
stevensJourney 6f0e630
Table updates from PowerSync side
stevensJourney 41174b1
Use SQLite Session API for PowerSync updates.
stevensJourney 7aae6cf
Update GRDB dependency
stevensJourney e970fd4
Merge remote-tracking branch 'origin/main' into grdb
stevensJourney 76aeb1c
demo update
stevensJourney 281558a
Update README. Cleanup public APIs. WIP WatchOS.
stevensJourney 9085743
Update Kotlin SDK to 1.7.0
simolus3 7beff16
Merge remote-tracking branch 'origin/main' into grdb
stevensJourney a81986e
Update READMEs
stevensJourney 1c1f2bb
Register extension on WatchOS
stevensJourney 9f457dc
Test encryption
simolus3 6afa299
Swift Strict Concurrency
stevensJourney b4d9cbf
Demo and Docs cleanup
stevensJourney 82880a4
Prepare for Kotlin common module
simolus3 ebacd30
Update PowerSync Kotlin and core extension
simolus3 858640f
Fix tests
simolus3 8300d80
Remove explicit Swift 6 test
simolus3 3a4fb66
Try initializing SQLite
simolus3 e1aca1a
Explicitly pass threadsafe 2
simolus3 6913958
typo
simolus3 241e322
Merge remote-tracking branch 'origin/pre-update-kotlin' into grdb-csq…
stevensJourney 06486f6
init csqlite
stevensJourney 36a3b76
Test: use SQLCipher
stevensJourney da4fc8c
close pool between tests
stevensJourney 9e347cf
cleanup docs
stevensJourney 2f643fb
Merge remote-tracking branch 'origin/encryption' into grdb-csqlite
stevensJourney 41aafe1
Export resolvePowerSyncLoadableExtensionPath from PowerSync SDK.
stevensJourney 27512a8
Export resolvePowerSyncLoadableExtensionPath from PowerSync SDK.
stevensJourney fa38d31
delete unused demo tests
stevensJourney 2b4d017
Merge branch 'grdb' into grdb-csqlite
stevensJourney fe8d65c
delete duplicate code block
stevensJourney c520836
delete duplicate code block
stevensJourney 7f4dac9
Merge branch 'grdb' into grdb-csqlite
stevensJourney 6a54ef1
Update README.md
stevensJourney 5efbef4
Update README.md
stevensJourney 283c42c
Avoid casting in kotlinWithSession
stevensJourney 91d48b9
Update WatchOS extension loading
stevensJourney c0d27c9
Fix withAllConnections issue
stevensJourney 01b5aa1
update demo app
stevensJourney 4f112b2
Avoid casting in kotlinWithSession
stevensJourney 81074db
Update WatchOS extension loading
stevensJourney f08484e
Fix withAllConnections issue
stevensJourney b35fb59
Prepare to use our CSQLite fork
simolus3 b8df805
Test with Swift 5
simolus3 9c2cb29
use git dependency for csqlite
stevensJourney 245bd01
Merge branch 'pre-update-kotlin' into grdb-csqlite
stevensJourney 6134b96
Merge branch 'grdb-csqlite' into grdb
stevensJourney 4660475
update grdb-main
stevensJourney aa24371
Merge remote-tracking branch 'origin/main' into grdb
stevensJourney 298c3b0
update demo
stevensJourney aacaf3a
add limitations
stevensJourney 0c3b5ab
cleanup
stevensJourney 7124713
use different db for different tests
stevensJourney 67f2b71
clear schema cache when updating schema
stevensJourney d1f0573
remove test logs
stevensJourney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Sources/PowerSyncGRDB/Config/Configuration+PowerSync.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import Foundation | ||
| import GRDB | ||
| import PowerSync | ||
| import SQLite3 | ||
|
|
||
| /// Extension for GRDB `Configuration` to add PowerSync support. | ||
| /// | ||
| /// Call `configurePowerSync(schema:)` on your existing GRDB `Configuration` to: | ||
| /// - Register the PowerSync SQLite core extension (required for PowerSync features). | ||
| /// - Add PowerSync schema views to your database schema source. | ||
| /// | ||
| /// This enables PowerSync replication and view management in your GRDB database. | ||
| /// | ||
| /// Example usage: | ||
| /// ```swift | ||
| /// var config = Configuration() | ||
| /// config.configurePowerSync(schema: mySchema) | ||
| /// let dbQueue = try DatabaseQueue(path: dbPath, configuration: config) | ||
| /// ``` | ||
| /// | ||
| /// - Parameter schema: The PowerSync `Schema` describing your sync views. | ||
| public extension Configuration { | ||
| mutating func configurePowerSync( | ||
| schema: Schema | ||
| ) { | ||
| // Register the PowerSync core extension | ||
| prepareDatabase { database in | ||
| guard let bundle = Bundle(identifier: "co.powersync.sqlitecore") else { | ||
| throw PowerSyncGRDBError.coreBundleNotFound | ||
| } | ||
|
|
||
| // Construct the full path to the shared library inside the bundle | ||
| let fullPath = bundle.bundlePath + "/powersync-sqlite-core" | ||
|
|
||
| let extensionLoadResult = sqlite3_enable_load_extension(database.sqliteConnection, 1) | ||
| if extensionLoadResult != SQLITE_OK { | ||
| throw PowerSyncGRDBError.extensionLoadFailed("Could not enable extension loading") | ||
| } | ||
| var errorMsg: UnsafeMutablePointer<Int8>? | ||
| let loadResult = sqlite3_load_extension(database.sqliteConnection, fullPath, "sqlite3_powersync_init", &errorMsg) | ||
| if loadResult != SQLITE_OK { | ||
| if let errorMsg = errorMsg { | ||
| let message = String(cString: errorMsg) | ||
| sqlite3_free(errorMsg) | ||
| throw PowerSyncGRDBError.extensionLoadFailed(message) | ||
| } else { | ||
| throw PowerSyncGRDBError.unknownExtensionLoadError | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Supply the PowerSync views as a SchemaSource | ||
| let powerSyncSchemaSource = PowerSyncSchemaSource( | ||
| schema: schema | ||
| ) | ||
| if let schemaSource = schemaSource { | ||
| self.schemaSource = schemaSource.then(powerSyncSchemaSource) | ||
| } else { | ||
| schemaSource = powerSyncSchemaSource | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.