diff --git a/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index c108a80b..1f352895 100644 --- a/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -123,8 +123,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-structured-queries", "state" : { - "revision" : "adad5c6c5abe0c62f93c573de5be071043f621a8", - "version" : "0.17.0" + "revision" : "49f18c24145a6e061cc581662f468b7c18523b8d", + "version" : "0.18.0" } }, { diff --git a/Examples/SyncUps/SyncUpForm.swift b/Examples/SyncUps/SyncUpForm.swift index 664a2a56..1fd2b915 100644 --- a/Examples/SyncUps/SyncUpForm.swift +++ b/Examples/SyncUps/SyncUpForm.swift @@ -76,11 +76,14 @@ final class SyncUpFormModel: Identifiable { } withErrorReporting { try database.write { db in - let syncUpID = try SyncUp.upsert(syncUp).returning(\.id).fetchOne(db)! + let syncUpID = try SyncUp.upsert { syncUp }.returning(\.id).fetchOne(db)! try Attendee.where { $0.syncUpID == syncUpID }.delete().execute(db) - try Attendee - .insert(attendees.map { Attendee.Draft(name: $0.name, syncUpID: syncUpID) }) - .execute(db) + try Attendee.insert { + for attendee in attendees { + Attendee.Draft(name: attendee.name, syncUpID: syncUpID) + } + } + .execute(db) } } isDismissed = true diff --git a/Package.resolved b/Package.resolved index d2942708..47cd361e 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "3b49a4e324dfd736adfe38cb30f7c3a771fb77d8faee549e703df3e8b4f7f8fd", + "originHash" : "3a7b88b10aac321547bc7235de2c7480456aca2003491837d36ba7dea7636a30", "pins" : [ { "identity" : "combine-schedulers", @@ -123,8 +123,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-structured-queries", "state" : { - "revision" : "adad5c6c5abe0c62f93c573de5be071043f621a8", - "version" : "0.17.0" + "revision" : "49f18c24145a6e061cc581662f468b7c18523b8d", + "version" : "0.18.0" } }, { diff --git a/Package.swift b/Package.swift index 9c740c67..ad14a969 100644 --- a/Package.swift +++ b/Package.swift @@ -36,7 +36,7 @@ let package = Package( .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.4"), .package( url: "https://github.com/pointfreeco/swift-structured-queries", - from: "0.17.0", + from: "0.18.0", traits: [ .trait(name: "StructuredQueriesTagged", condition: .when(traits: ["SQLiteDataTagged"])) ] diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift index b1241a7f..f69570ea 100644 --- a/Package@swift-6.0.swift +++ b/Package@swift-6.0.swift @@ -27,7 +27,7 @@ let package = Package( .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.9.0"), .package(url: "https://github.com/pointfreeco/swift-sharing", from: "2.3.0"), .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.4"), - .package(url: "https://github.com/pointfreeco/swift-structured-queries", from: "0.17.0"), + .package(url: "https://github.com/pointfreeco/swift-structured-queries", from: "0.18.0"), .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.5.0"), ], targets: [ diff --git a/Sources/SQLiteData/CloudKit/Internal/ForeignKey.swift b/Sources/SQLiteData/CloudKit/Internal/ForeignKey.swift index 4813283f..977dc785 100644 --- a/Sources/SQLiteData/CloudKit/Internal/ForeignKey.swift +++ b/Sources/SQLiteData/CloudKit/Internal/ForeignKey.swift @@ -2,60 +2,13 @@ import Foundation import StructuredQueriesCore - package struct ForeignKey: QueryDecodable, QueryRepresentable { - typealias QueryValue = Self - + @Selection + package struct ForeignKey { let table: String let from: String let to: String - let onUpdate: Action - let onDelete: Action - let notnull: Bool - - package init(decoder: inout some QueryDecoder) throws { - guard - let table = try decoder.decode(String.self), - let from = try decoder.decode(String.self), - let to = try decoder.decode(String.self), - let onUpdate = try decoder.decode(Action.self), - let onDelete = try decoder.decode(Action.self), - let notnull = try decoder.decode(Bool.self) - else { - throw QueryDecodingError.missingRequiredColumn - } - self.table = table - self.from = from - self.to = to - self.onUpdate = onUpdate - self.onDelete = onDelete - self.notnull = notnull - } - - enum Action: String, QueryBindable { - case cascade = "CASCADE" - case restrict = "RESTRICT" - case setDefault = "SET DEFAULT" - case setNull = "SET NULL" - case noAction = "NO ACTION" - } - - static func all( - _ tableName: String - ) -> some StructuredQueriesCore.Statement { - #sql( - """ - SELECT \(columns) - FROM pragma_foreign_key_list(\(bind: tableName)) AS "foreign_keys" - JOIN pragma_table_info(\(bind: tableName)) AS "table_info" - ON "foreign_keys"."from" = "table_info"."name" - """ - ) - } - - static var columns: QueryFragment { - """ - "table", "from", "to", "on_update", "on_delete", "notnull" - """ - } + let onUpdate: ForeignKeyAction + let onDelete: ForeignKeyAction + let isNotNull: Bool } #endif diff --git a/Sources/SQLiteData/CloudKit/Internal/Pragmas.swift b/Sources/SQLiteData/CloudKit/Internal/Pragmas.swift new file mode 100644 index 00000000..d384415a --- /dev/null +++ b/Sources/SQLiteData/CloudKit/Internal/Pragmas.swift @@ -0,0 +1,64 @@ +@Table +struct PragmaDatabaseList { + static var tableAlias: String? { "databases" } + static var tableFragment: QueryFragment { "pragma_database_list()" } + + @Column("seq") let sequence: Int + let name: String + let file: String +} + +@Table +struct PragmaForeignKeyList { + static var tableAlias: String? { "\(Base.tableName)ForeignKeys" } + static var tableFragment: QueryFragment { + "pragma_foreign_key_list(\(quote: Base.tableName, delimiter: .text))" + } + + let id: Int + @Column("seq") let sequence: Int + let table: String + let from: String + let to: String + @Column("on_update") let onUpdate: ForeignKeyAction + @Column("on_delete") let onDelete: ForeignKeyAction + let match: String +} + +package enum ForeignKeyAction: String, QueryBindable { + case cascade = "CASCADE" + case restrict = "RESTRICT" + case setDefault = "SET DEFAULT" + case setNull = "SET NULL" + case noAction = "NO ACTION" +} + +@Table +struct PragmaIndexList { + static var tableAlias: String? { "\(Base.tableName)Indices" } + static var tableFragment: QueryFragment { + "pragma_index_list(\(quote: Base.tableName, delimiter: .text))" + } + + @Column("seq") let sequence: Int + let name: String + @Column("unique") let isUnique: Bool + let origin: String + @Column("partial") let isPartial: Bool +} + +@Table +struct PragmaTableInfo { + static var tableAlias: String? { "\(Base.tableName)TableInfo" } + static var schemaName: String? { Base.schemaName } + static var tableFragment: QueryFragment { + "pragma_table_info(\(quote: Base.tableName, delimiter: .text))" + } + + @Column("cid") let columnID: Int + let name: String + let type: String + @Column("notnull") let isNotNull: Bool + @Column("dflt_value") let defaultValue: String? + @Column("pk") let isPrimaryKey: Bool +} diff --git a/Sources/SQLiteData/CloudKit/Internal/TableInfo.swift b/Sources/SQLiteData/CloudKit/Internal/TableInfo.swift index 462615b8..1b416666 100644 --- a/Sources/SQLiteData/CloudKit/Internal/TableInfo.swift +++ b/Sources/SQLiteData/CloudKit/Internal/TableInfo.swift @@ -1,44 +1,10 @@ import StructuredQueriesCore +@Selection package struct TableInfo: Codable, Hashable, QueryDecodable, QueryRepresentable { - typealias QueryValue = Self - let defaultValue: String? let isPrimaryKey: Bool let name: String - let notNull: Bool + let isNotNull: Bool let type: String - - package init(decoder: inout some QueryDecoder) throws { - self.defaultValue = try decoder.decode(String.self) - guard - let isPrimaryKey = try decoder.decode(Bool.self), - let name = try decoder.decode(String.self), - let notNull = try decoder.decode(Bool.self), - let type = try decoder.decode(String.self) - else { - throw QueryDecodingError.missingRequiredColumn - } - self.isPrimaryKey = isPrimaryKey - self.name = name - self.notNull = notNull - self.type = type - } - - static func all( - _ tableName: String - ) -> some StructuredQueriesCore.Statement { - #sql( - """ - SELECT \(columns) FROM pragma_table_info(\(bind: tableName)) - """, - as: Self.self - ) - } - - static var columns: QueryFragment { - """ - "dflt_value", "pk", "name", "notnull", "type" - """ - } } diff --git a/Sources/SQLiteData/CloudKit/SyncEngine.swift b/Sources/SQLiteData/CloudKit/SyncEngine.swift index af81fb75..06450fc1 100644 --- a/Sources/SQLiteData/CloudKit/SyncEngine.swift +++ b/Sources/SQLiteData/CloudKit/SyncEngine.swift @@ -207,10 +207,25 @@ let foreignKeysByTableName = Dictionary( uniqueKeysWithValues: try userDatabase.read { db in try allTables.map { table -> (String, [ForeignKey]) in - ( - table.tableName, - try ForeignKey.all(table.tableName).fetchAll(db) - ) + func open(_: T.Type) throws -> (String, [ForeignKey]) { + ( + table.tableName, + try PragmaForeignKeyList + .join(PragmaTableInfo.all) { $0.from.eq($1.name) } + .select { + ForeignKey.Columns( + table: $0.table, + from: $0.from, + to: $0.to, + onUpdate: $0.onUpdate, + onDelete: $0.onDelete, + isNotNull: $1.isNotNull + ) + } + .fetchAll(db) + ) + } + return try open(table) } } ) @@ -257,14 +272,9 @@ try userDatabase.write { db in let attachedMetadatabasePath: String? = - try #sql( - """ - SELECT "file" - FROM pragma_database_list() - WHERE "name" = \(bind: String.sqliteDataCloudKitSchemaName) - """, - as: String.self - ) + try PragmaDatabaseList + .where { $0.name.eq(String.sqliteDataCloudKitSchemaName) } + .select(\.file) .fetchOne(db) if let attachedMetadatabasePath { let attachedMetadatabaseName = URL(filePath: metadatabase.path).lastPathComponent @@ -366,13 +376,28 @@ } .fetchAll(db) return try namesAndSchemas.compactMap { schema -> RecordType? in - guard let sql = schema.sql + guard let sql = schema.sql, let table = tablesByName[schema.name] else { return nil } - return RecordType( - tableName: schema.name, - schema: sql, - tableInfo: Set(try TableInfo.all(schema.name).fetchAll(db)) - ) + func open(_: T.Type) throws -> RecordType { + try RecordType( + tableName: schema.name, + schema: sql, + tableInfo: Set( + PragmaTableInfo + .select { + TableInfo.Columns( + defaultValue: $0.defaultValue, + isPrimaryKey: $0.isPrimaryKey, + name: $0.name, + isNotNull: $0.isNotNull, + type: $0.type + ) + } + .fetchAll(db) + ) + ) + } + return try open(table) } } let previousRecordTypeByTableName = Dictionary( @@ -1747,13 +1772,7 @@ ) } - let databasePath = try #sql( - """ - SELECT "file" FROM pragma_database_list() - """, - as: String.self - ) - .fetchOne(self) + let databasePath = try PragmaDatabaseList.select(\.file).fetchOne(self) guard let databasePath else { struct PathError: Error {} throw SyncEngine.SchemaError( @@ -1847,23 +1866,21 @@ } for table in tables { - let columnsWithUniqueConstraints = - try #sql( - """ - SELECT "name" FROM pragma_index_list(\(quote: table.tableName, delimiter: .text)) - WHERE "unique" = 1 AND "origin" <> 'pk' - """, - as: String.self - ) - .fetchAll(db) - if !columnsWithUniqueConstraints.isEmpty { - throw SyncEngine.SchemaError( - reason: .uniquenessConstraint, - debugDescription: """ + func open(_: T.Type) throws { + let columnsWithUniqueConstraints = try PragmaIndexList + .where { $0.isUnique && $0.origin != "pk" } + .select(\.name) + .fetchAll(db) + if !columnsWithUniqueConstraints.isEmpty { + throw SyncEngine.SchemaError( + reason: .uniquenessConstraint, + debugDescription: """ Uniqueness constraints are not supported for synchronized tables. """ - ) + ) + } } + try open(table) } } } @@ -1891,13 +1908,11 @@ let tableDependencies = try userDatabase.read { db in var dependencies: [HashablePrimaryKeyedTableType: [any PrimaryKeyedTable.Type]] = [:] for table in tables { - let toTables = try #sql( - """ - SELECT "table" FROM pragma_foreign_key_list(\(quote: table.tableName, delimiter: .text)) - """, - as: String.self - ) - .fetchAll(db) + func open(_: T.Type) throws -> [String] { + try PragmaForeignKeyList.select(\.table) + .fetchAll(db) + } + let toTables = try open(table) for toTable in toTables { guard let toTableType = tablesByName[toTable] else { continue } diff --git a/Tests/SQLiteDataTests/CloudKitTests/CloudKitTests.swift b/Tests/SQLiteDataTests/CloudKitTests/CloudKitTests.swift index e3a06d93..b2a2d4bd 100644 --- a/Tests/SQLiteDataTests/CloudKitTests/CloudKitTests.swift +++ b/Tests/SQLiteDataTests/CloudKitTests/CloudKitTests.swift @@ -33,14 +33,14 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "\'\'", isPrimaryKey: false, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -59,21 +59,21 @@ defaultValue: nil, isPrimaryKey: false, name: "coverImage", - notNull: true, + isNotNull: true, type: "BLOB" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "remindersListID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -92,21 +92,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "position", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "remindersListID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -130,42 +130,42 @@ defaultValue: nil, isPrimaryKey: false, name: "dueDate", - notNull: false, + isNotNull: false, type: "TEXT" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "isCompleted", - notNull: true, + isNotNull: true, type: "INTEGER" ), [3]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "priority", - notNull: false, + isNotNull: false, type: "INTEGER" ), [4]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "remindersListID", - notNull: true, + isNotNull: true, type: "INTEGER" ), [5]: TableInfo( defaultValue: "\'\'", isPrimaryKey: false, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -182,7 +182,7 @@ defaultValue: nil, isPrimaryKey: true, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -201,21 +201,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "reminderID", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "tagID", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -232,7 +232,7 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -250,14 +250,14 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "parentID", - notNull: false, + isNotNull: false, type: "INTEGER" ) ] @@ -276,14 +276,14 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "parentID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -302,14 +302,14 @@ defaultValue: "0", isPrimaryKey: false, name: "count", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -328,21 +328,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "isOn", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "modelAID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -361,21 +361,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "modelBID", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: "\'\'", isPrimaryKey: false, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] diff --git a/Tests/SQLiteDataTests/CloudKitTests/RecordTypeTests.swift b/Tests/SQLiteDataTests/CloudKitTests/RecordTypeTests.swift index 6853cc5c..af2e86ca 100644 --- a/Tests/SQLiteDataTests/CloudKitTests/RecordTypeTests.swift +++ b/Tests/SQLiteDataTests/CloudKitTests/RecordTypeTests.swift @@ -31,14 +31,14 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "\'\'", isPrimaryKey: false, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -57,21 +57,21 @@ defaultValue: nil, isPrimaryKey: false, name: "coverImage", - notNull: true, + isNotNull: true, type: "BLOB" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "remindersListID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -90,21 +90,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "position", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "remindersListID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -128,42 +128,42 @@ defaultValue: nil, isPrimaryKey: false, name: "dueDate", - notNull: false, + isNotNull: false, type: "TEXT" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "isCompleted", - notNull: true, + isNotNull: true, type: "INTEGER" ), [3]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "priority", - notNull: false, + isNotNull: false, type: "INTEGER" ), [4]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "remindersListID", - notNull: true, + isNotNull: true, type: "INTEGER" ), [5]: TableInfo( defaultValue: "\'\'", isPrimaryKey: false, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -180,7 +180,7 @@ defaultValue: nil, isPrimaryKey: true, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -199,21 +199,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "reminderID", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "tagID", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -230,7 +230,7 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -248,14 +248,14 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "parentID", - notNull: false, + isNotNull: false, type: "INTEGER" ) ] @@ -274,14 +274,14 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "parentID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -300,14 +300,14 @@ defaultValue: "0", isPrimaryKey: false, name: "count", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -326,21 +326,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "isOn", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "modelAID", - notNull: true, + isNotNull: true, type: "INTEGER" ) ] @@ -359,21 +359,21 @@ defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "modelBID", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: "\'\'", isPrimaryKey: false, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] @@ -459,49 +459,49 @@ defaultValue: nil, isPrimaryKey: false, name: "dueDate", - notNull: false, + isNotNull: false, type: "TEXT" ), [1]: TableInfo( defaultValue: nil, isPrimaryKey: true, name: "id", - notNull: true, + isNotNull: true, type: "INTEGER" ), [2]: TableInfo( defaultValue: "0", isPrimaryKey: false, name: "isCompleted", - notNull: true, + isNotNull: true, type: "INTEGER" ), [3]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "newFeature", - notNull: true, + isNotNull: true, type: "INTEGER" ), [4]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "priority", - notNull: false, + isNotNull: false, type: "INTEGER" ), [5]: TableInfo( defaultValue: nil, isPrimaryKey: false, name: "remindersListID", - notNull: true, + isNotNull: true, type: "INTEGER" ), [6]: TableInfo( defaultValue: "\'\'", isPrimaryKey: false, name: "title", - notNull: true, + isNotNull: true, type: "TEXT" ) ] diff --git a/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift b/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift index d6d63194..ed2856e5 100644 --- a/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift +++ b/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift @@ -46,7 +46,7 @@ to: "id", onUpdate: .cascade, onDelete: .cascade, - notnull: true + isNotNull: true ) ] ), @@ -113,7 +113,7 @@ to: "id", onUpdate: .noAction, onDelete: .cascade, - notnull: true + isNotNull: true ) ] ), diff --git a/Tests/SQLiteDataTests/CloudKitTests/SyncEngineValidationTests.swift b/Tests/SQLiteDataTests/CloudKitTests/SyncEngineValidationTests.swift index c0734ebb..5b24fe01 100644 --- a/Tests/SQLiteDataTests/CloudKitTests/SyncEngineValidationTests.swift +++ b/Tests/SQLiteDataTests/CloudKitTests/SyncEngineValidationTests.swift @@ -96,7 +96,7 @@ to: "id", onUpdate: .noAction, onDelete: .noAction, - notnull: false + isNotNull: false ) ), debugDescription: #"Foreign key "childs"."parentID" action not supported. Must be 'CASCADE', 'SET DEFAULT' or 'SET NULL'."# @@ -155,7 +155,7 @@ to: "id", onUpdate: .noAction, onDelete: .restrict, - notnull: false + isNotNull: false ) ), debugDescription: #"Foreign key "childs"."parentID" action not supported. Must be 'CASCADE', 'SET DEFAULT' or 'SET NULL'."# @@ -221,7 +221,7 @@ to: "id", onUpdate: .noAction, onDelete: .cascade, - notnull: false + isNotNull: false ) ), debugDescription: #"Foreign key "childs"."parentID" references table "parents" that is not synchronized. Update 'SyncEngine.init' to synchronize "parents". "#