Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 32 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swift-tools-version: 6.1

import PackageDescription

let package = Package(
Expand All @@ -21,14 +20,31 @@ let package = Package(
),
],
traits: [
.default(enabledTraits: ["GRDB"]),
.trait(
name: "GRDB",
description: "Use the standard GRDB package."
),
.trait(
name: "SQLiteDataTagged",
description: "Introduce SQLiteData conformances to the swift-tagged package."
),
.trait(
name: "GRDBCIPHER",
description: "Use the SQLCipher-backed GRDB package."
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-collections", from: "1.0.0"),
.package(url: "https://github.com/groue/GRDB.swift", from: "7.6.0"),
Comment thread
woodymelling marked this conversation as resolved.
.package(
url: "https://github.com/swift-everywhere/grdb-sqlcipher.git",
from: "7.5.0",
traits: [
.trait(name: "GRDBCIPHER", condition: .when(traits: ["GRDBCIPHER"]))
]
),
.package(url: "https://github.com/skiptools/swift-sqlcipher.git", from: "1.3.0"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.9.0"),
Expand All @@ -51,11 +67,25 @@ let package = Package(
dependencies: [
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "GRDB", package: "GRDB.swift"),
.product(
name: "GRDB",
package: "GRDB.swift",
condition: .when(traits: ["GRDB"])
),
.product(
name: "GRDB",
package: "grdb-sqlcipher",
condition: .when(traits: ["GRDBCIPHER"])
),
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
.product(name: "OrderedCollections", package: "swift-collections"),
.product(name: "Perception", package: "swift-perception"),
.product(name: "Sharing", package: "swift-sharing"),
.product(
name: "SQLCipher",
package: "swift-sqlcipher",
condition: .when(traits: ["GRDBCIPHER"])
),
.product(name: "StructuredQueriesSQLite", package: "swift-structured-queries"),
.product(
name: "Tagged",
Expand Down
4 changes: 2 additions & 2 deletions Sources/SQLiteData/CloudKit/Internal/UserDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}

package func write<T: Sendable>(
_ updates: @Sendable (Database) throws -> T
_ updates: @escaping @Sendable (Database) throws -> T
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is necessary? The database.write method in GRDB being called below only requires a @Sendable closure.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a req of the current swift-everywhere/grdb-sqlcipher fork.

I'm looking into why that's happening, and if it's a straightforward update.
I'll mark this as draft until we're able to squash this back to the GRDB shape.

) async throws -> T {
try await database.write { db in
try $_isSynchronizingChanges.withValue(true) {
Expand All @@ -26,7 +26,7 @@
}

package func read<T: Sendable>(
_ updates: @Sendable (Database) throws -> T
_ updates: @escaping @Sendable (Database) throws -> T
) async throws -> T {
try await database.read { db in
try updates(db)
Expand Down
8 changes: 4 additions & 4 deletions Sources/SQLiteData/CloudKit/SyncEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,15 @@
try tearDownSyncEngine()
await withErrorReporting(.sqliteDataCloudKitFailure) {
try await userDatabase.write { db in
for table in tables {
for table in self.tables {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because Skip/Android is using an older version of Swift that doesn't allow an implicit self? Or something else?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is fallout from making this escaping.
Hopefully the final patch will just be the import changes

func open<T>(_: some SynchronizableTable<T>) {
withErrorReporting(.sqliteDataCloudKitFailure) {
try T.delete().execute(db)
}
}
open(table)
}
try setUpSyncEngine(writableDB: db)
try self.setUpSyncEngine(writableDB: db)
}
}
try await start()
Expand Down Expand Up @@ -1591,7 +1591,7 @@
if let share = record as? CKShare {
shares.append(.share(share))
} else {
upsertFromServerRecord(record, db: db)
self.upsertFromServerRecord(record, db: db)
if let shareReference = record.share {
shares.append(.reference(shareReference))
}
Expand Down Expand Up @@ -1893,7 +1893,7 @@
) async {
await withErrorReporting(.sqliteDataCloudKitFailure) {
try await userDatabase.write { db in
upsertFromServerRecord(serverRecord, force: force, db: db)
self.upsertFromServerRecord(serverRecord, force: force, db: db)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Foundation
#if GRDBCIPHER
import SQLCipher
#else
import GRDBSQLite
#endif

extension Database {
/// Adds a user-defined scalar `@DatabaseFunction` to a connection.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SQLiteData/StructuredQueries+GRDB/QueryCursor.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Foundation
import GRDB
#if GRDBCIPHER
import SQLCipher
#else
import GRDBSQLite
#endif
import StructuredQueriesCore

/// A cursor of a structured query.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Foundation
#if GRDBCIPHER
import SQLCipher
#else
import GRDBSQLite
#endif
import StructuredQueriesCore

@usableFromInline
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Foundation
#if GRDBCIPHER
import SQLCipher
#else
import GRDBSQLite
#endif
import StructuredQueriesCore

@usableFromInline
Expand Down