Skip to content

Commit 3209c98

Browse files
Upstream Updates (#32)
1 parent 9cb306f commit 3209c98

File tree

7 files changed

+68
-12
lines changed

7 files changed

+68
-12
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 1.0.0-Beta.9
4+
5+
* Update PowerSync SQLite core extension to 0.3.12.
6+
* Added queuing protection and warnings when connecting multiple PowerSync clients to the same database file.
7+
* Improved concurrent SQLite connection support. A single write connection and multiple read connections are used for concurrent read queries.
8+
* Internally improved the linking of SQLite.
9+
* Enabled Full Text Search support.
10+
* Added the ability to update the schema for existing PowerSync clients.
11+
* Fixed bug where local only, insert only and view name overrides were not applied for schema tables.
12+
313
## 1.0.0-Beta.8
414

515
* Improved watch query internals. Added the ability to throttle watched queries.

Demo/PowerSyncExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let package = Package(
1616
targets: ["PowerSync"]),
1717
],
1818
dependencies: [
19-
.package(url: "https://github.com/powersync-ja/powersync-kotlin.git", exact: "1.0.0-BETA27.0"),
20-
.package(url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", "0.3.11"..<"0.4.0")
19+
.package(url: "https://github.com/powersync-ja/powersync-kotlin.git", exact: "1.0.0-BETA28.0"),
20+
.package(url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", "0.3.12"..<"0.4.0")
2121
],
2222
targets: [
2323
// Targets are the basic building blocks of a package, defining a module or a test suite.

Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol {
2626
try await kotlinDatabase.waitForFirstSync()
2727
}
2828

29+
func updateSchema(schema: any SchemaProtocol) async throws {
30+
try await kotlinDatabase.updateSchema(schema: KotlinAdapter.Schema.toKotlin(schema))
31+
}
32+
2933
func waitForFirstSync(priority: Int32) async throws {
3034
try await kotlinDatabase.waitForFirstSync(priority: priority)
3135
}

Sources/PowerSync/PowerSyncDatabaseProtocol.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public protocol PowerSyncDatabaseProtocol: Queries {
1313

1414
/// Wait for the first sync to occur
1515
func waitForFirstSync() async throws
16+
17+
18+
/// Replace the schema with a new version. This is for advanced use cases - typically the schema
19+
/// should just be specified once in the constructor.
20+
///
21+
/// Cannot be used while connected - this should only be called before connect.
22+
func updateSchema(schema: SchemaProtocol) async throws
1623

1724
/// Wait for the first (possibly partial) sync to occur that contains all buckets in the given priority.
1825
func waitForFirstSync(priority: Int32) async throws

Tests/PowerSyncTests/Kotlin/KotlinPowerSyncDatabaseImplTests.swift

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ final class KotlinPowerSyncDatabaseImplTests: XCTestCase {
213213
}
214214
}
215215

216-
217216
let resultsStore = ResultsStore()
218217

219218
let stream = try database.watch(
@@ -242,7 +241,6 @@ final class KotlinPowerSyncDatabaseImplTests: XCTestCase {
242241
sql: "INSERT INTO users (id, name, email) VALUES (?, ?, ?)",
243242
parameters: ["2", "User 2", "user2@example.com"]
244243
)
245-
246244

247245
await fulfillment(of: [expectation], timeout: 5)
248246
watchTask.cancel()
@@ -433,4 +431,41 @@ final class KotlinPowerSyncDatabaseImplTests: XCTestCase {
433431
""")
434432
}
435433
}
434+
435+
func testFTS() async throws {
436+
let supported = try await database.get(
437+
"SELECT sqlite_compileoption_used('ENABLE_FTS5');"
438+
) { cursor in
439+
cursor.getLong(index: 0)
440+
}
441+
442+
XCTAssertEqual(supported, 1)
443+
}
444+
445+
func testUpdatingSchema() async throws {
446+
_ = try await database.execute(
447+
sql: "INSERT INTO users (id, name, email) VALUES (?, ?, ?)",
448+
parameters: ["1", "Test User", "test@example.com"]
449+
)
450+
451+
let newSchema = Schema(tables: [
452+
Table(
453+
name: "users",
454+
columns: [
455+
.text("name"),
456+
.text("email"),
457+
],
458+
viewNameOverride: "people"
459+
),
460+
])
461+
462+
try await database.updateSchema(schema: newSchema)
463+
464+
let peopleCount = try await database.get(
465+
sql: "SELECT COUNT(*) FROM people",
466+
parameters: []
467+
) { cursor in cursor.getLong(index: 0) }
468+
469+
XCTAssertEqual(peopleCount, 1)
470+
}
436471
}

0 commit comments

Comments
 (0)