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

+10
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
"kind" : "remoteSourceControl",
1616
"location" : "https://github.com/powersync-ja/powersync-kotlin.git",
1717
"state" : {
18-
"revision" : "cb1a7d186144290b5ad706f5c2c9b67ff707356e",
19-
"version" : "1.0.0-BETA27.0"
18+
"revision" : "443df078f4b9352de137000b993d564d4ab019b7",
19+
"version" : "1.0.0-BETA28.0"
2020
}
2121
},
2222
{
2323
"identity" : "powersync-sqlite-core-swift",
2424
"kind" : "remoteSourceControl",
2525
"location" : "https://github.com/powersync-ja/powersync-sqlite-core-swift.git",
2626
"state" : {
27-
"revision" : "fb313c473b17457d79bf3847905f5a288901d493",
28-
"version" : "0.3.11"
27+
"revision" : "5041116d295e61d3c54f27117c02fd81071a1ab3",
28+
"version" : "0.3.12"
2929
}
3030
},
3131
{

Package.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"kind" : "remoteSourceControl",
66
"location" : "https://github.com/powersync-ja/powersync-kotlin.git",
77
"state" : {
8-
"revision" : "cb1a7d186144290b5ad706f5c2c9b67ff707356e",
9-
"version" : "1.0.0-BETA27.0"
8+
"revision" : "443df078f4b9352de137000b993d564d4ab019b7",
9+
"version" : "1.0.0-BETA28.0"
1010
}
1111
},
1212
{
1313
"identity" : "powersync-sqlite-core-swift",
1414
"kind" : "remoteSourceControl",
1515
"location" : "https://github.com/powersync-ja/powersync-sqlite-core-swift.git",
1616
"state" : {
17-
"revision" : "fb313c473b17457d79bf3847905f5a288901d493",
18-
"version" : "0.3.11"
17+
"revision" : "5041116d295e61d3c54f27117c02fd81071a1ab3",
18+
"version" : "0.3.12"
1919
}
2020
}
2121
],

Package.swift

+2-2
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

+4
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

+7
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

+37-2
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", "[email protected]"]
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", "[email protected]"]
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)