diff --git a/Tests/GRDBTests/AssociationAggregateTests.swift b/Tests/GRDBTests/AssociationAggregateTests.swift index 8d4333a26..a29ece144 100644 --- a/Tests/GRDBTests/AssociationAggregateTests.swift +++ b/Tests/GRDBTests/AssociationAggregateTests.swift @@ -51,13 +51,13 @@ class AssociationAggregateTests: GRDBTestCase { } try db.create(table: "player") { t in t.primaryKey("id", .integer) - t.column("teamId", .integer).references("team") + t.belongsTo("team") t.column("name", .text) t.column("score", .integer) } try db.create(table: "award") { t in t.primaryKey("customPrimaryKey", .integer) - t.column("teamId", .integer).references("team") + t.belongsTo("team") t.column("name", .text) } diff --git a/Tests/GRDBTests/AssociationBelongsToDecodableRecordTests.swift b/Tests/GRDBTests/AssociationBelongsToDecodableRecordTests.swift index 161e8e148..bdfac0827 100644 --- a/Tests/GRDBTests/AssociationBelongsToDecodableRecordTests.swift +++ b/Tests/GRDBTests/AssociationBelongsToDecodableRecordTests.swift @@ -55,7 +55,7 @@ class AssociationBelongsToDecodableRecordTests: GRDBTestCase { } try db.create(table: "players") { t in t.primaryKey("id", .integer) - t.column("teamId", .integer).references("teams") + t.belongsTo("team") t.column("name", .text) } diff --git a/Tests/GRDBTests/AssociationBelongsToFetchableRecordTests.swift b/Tests/GRDBTests/AssociationBelongsToFetchableRecordTests.swift index 06e63f47a..e288e6c0c 100644 --- a/Tests/GRDBTests/AssociationBelongsToFetchableRecordTests.swift +++ b/Tests/GRDBTests/AssociationBelongsToFetchableRecordTests.swift @@ -57,7 +57,7 @@ class AssociationBelongsToFetchableRecordTests: GRDBTestCase { } try db.create(table: "players") { t in t.primaryKey("id", .integer) - t.column("teamId", .integer).references("teams") + t.belongsTo("team") t.column("name", .text) } diff --git a/Tests/GRDBTests/AssociationBelongsToRowScopeTests.swift b/Tests/GRDBTests/AssociationBelongsToRowScopeTests.swift index b7f826ab0..813a993e2 100644 --- a/Tests/GRDBTests/AssociationBelongsToRowScopeTests.swift +++ b/Tests/GRDBTests/AssociationBelongsToRowScopeTests.swift @@ -27,7 +27,7 @@ class AssociationBelongsToRowScopeTests: GRDBTestCase { } try db.create(table: "players") { t in t.primaryKey("id", .integer) - t.column("teamId", .integer).references("teams") + t.belongsTo("team") t.column("name", .text) } diff --git a/Tests/GRDBTests/AssociationBelongsToSQLTests.swift b/Tests/GRDBTests/AssociationBelongsToSQLTests.swift index c56904732..75f26a493 100644 --- a/Tests/GRDBTests/AssociationBelongsToSQLTests.swift +++ b/Tests/GRDBTests/AssociationBelongsToSQLTests.swift @@ -330,7 +330,7 @@ class AssociationBelongsToSQLTests: GRDBTestCase { t.column("name", .text) } try db.create(table: "children") { t in - t.column("parentId", .integer).references("parents") + t.belongsTo("parent") } } @@ -546,8 +546,8 @@ class AssociationBelongsToSQLTests: GRDBTestCase { t.column("name", .text) } try db.create(table: "children") { t in - t.column("parent1Id", .integer).references("parents") - t.column("parent2Id", .integer).references("parents") + t.belongsTo("parent1", inTable: "parents") + t.belongsTo("parent2", inTable: "parents") } } @@ -1742,7 +1742,7 @@ class AssociationBelongsToSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId", .integer).references("a") + t.belongsTo("a") } struct A: TableRecord { } struct B: TableRecord { } @@ -1771,7 +1771,7 @@ class AssociationBelongsToSQLTests: GRDBTestCase { t.column("name", .text) } try db.create(table: "children") { t in - t.column("parentId", .integer).references("parents") + t.belongsTo("parent") } } diff --git a/Tests/GRDBTests/AssociationHasManyOrderingTests.swift b/Tests/GRDBTests/AssociationHasManyOrderingTests.swift index 5feb757c9..dff328b69 100644 --- a/Tests/GRDBTests/AssociationHasManyOrderingTests.swift +++ b/Tests/GRDBTests/AssociationHasManyOrderingTests.swift @@ -36,7 +36,7 @@ class AssociationHasManyOrderingTests: GRDBTestCase { } try db.create(table: "player") { t in t.primaryKey("id", .integer) - t.column("teamId", .integer).notNull().references("team") + t.belongsTo("team").notNull() t.column("name", .text).notNull() t.column("position", .integer).notNull() } diff --git a/Tests/GRDBTests/AssociationHasManyRowScopeTests.swift b/Tests/GRDBTests/AssociationHasManyRowScopeTests.swift index a3d244ea9..69f450aa7 100644 --- a/Tests/GRDBTests/AssociationHasManyRowScopeTests.swift +++ b/Tests/GRDBTests/AssociationHasManyRowScopeTests.swift @@ -18,7 +18,7 @@ class AssociationHasManyRowScopeTests: GRDBTestCase { } try db.create(table: "child") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("parent") + t.belongsTo("parent") } try db.execute(sql: """ INSERT INTO parent (id) VALUES (1); @@ -49,7 +49,7 @@ class AssociationHasManyRowScopeTests: GRDBTestCase { } try db.create(table: "children") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("parents") + t.belongsTo("parent") } try db.execute(sql: """ INSERT INTO parents (id) VALUES (1); @@ -79,7 +79,7 @@ class AssociationHasManyRowScopeTests: GRDBTestCase { } try db.create(table: "child") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("parent") + t.belongsTo("parent") } try db.execute(sql: """ INSERT INTO parent (id) VALUES (1); diff --git a/Tests/GRDBTests/AssociationHasManySQLTests.swift b/Tests/GRDBTests/AssociationHasManySQLTests.swift index ffc3fcaab..f56133ab0 100644 --- a/Tests/GRDBTests/AssociationHasManySQLTests.swift +++ b/Tests/GRDBTests/AssociationHasManySQLTests.swift @@ -217,7 +217,7 @@ class AssociationHasManySQLTests: GRDBTestCase { t.primaryKey("id", .integer) } try db.create(table: "children") { t in - t.column("parentId", .integer).references("parents") + t.belongsTo("parent") } } @@ -346,8 +346,8 @@ class AssociationHasManySQLTests: GRDBTestCase { t.primaryKey("id", .integer) } try db.create(table: "children") { t in - t.column("parent1Id", .integer).references("parents") - t.column("parent2Id", .integer).references("parents") + t.belongsTo("parent1", inTable: "parents") + t.belongsTo("parent2", inTable: "parents") } } @@ -1074,10 +1074,10 @@ class AssociationHasManySQLTests: GRDBTestCase { } try db.create(table: "child") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("parent") + t.belongsTo("parent") } try db.create(table: "toy") { t in - t.column("childId", .integer).references("child") + t.belongsTo("child") } } diff --git a/Tests/GRDBTests/AssociationHasManyThroughOrderingTests.swift b/Tests/GRDBTests/AssociationHasManyThroughOrderingTests.swift index 79be3fa5e..0b9946192 100644 --- a/Tests/GRDBTests/AssociationHasManyThroughOrderingTests.swift +++ b/Tests/GRDBTests/AssociationHasManyThroughOrderingTests.swift @@ -40,8 +40,8 @@ class AssociationHasManyThroughOrderingTests: GRDBTestCase { t.column("name", .text).notNull() } try db.create(table: "playerRole") { t in - t.column("teamId", .integer).notNull().references("team") - t.column("playerId", .integer).notNull().references("player") + t.belongsTo("team").notNull() + t.belongsTo("player").notNull() t.column("position", .integer).notNull() t.primaryKey(["teamId", "playerId"]) } diff --git a/Tests/GRDBTests/AssociationHasManyThroughRowScopeTests.swift b/Tests/GRDBTests/AssociationHasManyThroughRowScopeTests.swift index 215720a6b..fbe43d7b5 100644 --- a/Tests/GRDBTests/AssociationHasManyThroughRowScopeTests.swift +++ b/Tests/GRDBTests/AssociationHasManyThroughRowScopeTests.swift @@ -23,11 +23,11 @@ class AssociationHasManyThroughRowScopeTests: GRDBTestCase { } try db.create(table: "parent") { t in t.autoIncrementedPrimaryKey("id") - t.column("childId").references("child") + t.belongsTo("child") } try db.create(table: "grandChild") { t in t.autoIncrementedPrimaryKey("id") - t.column("childId").references("child") + t.belongsTo("child") } try db.execute(sql: """ INSERT INTO child (id) VALUES (1); @@ -64,11 +64,11 @@ class AssociationHasManyThroughRowScopeTests: GRDBTestCase { } try db.create(table: "parents") { t in t.autoIncrementedPrimaryKey("id") - t.column("childId").references("children") + t.belongsTo("child") } try db.create(table: "grandChildren") { t in t.autoIncrementedPrimaryKey("id") - t.column("childId").references("children") + t.belongsTo("child") } try db.execute(sql: """ INSERT INTO children (id) VALUES (1); @@ -106,11 +106,11 @@ class AssociationHasManyThroughRowScopeTests: GRDBTestCase { } try db.create(table: "parents") { t in t.autoIncrementedPrimaryKey("id") - t.column("childId").references("children") + t.belongsTo("child") } try db.create(table: "grandChildren") { t in t.autoIncrementedPrimaryKey("id") - t.column("childId").references("children") + t.belongsTo("child") } try db.execute(sql: """ INSERT INTO children (id) VALUES (1); @@ -157,8 +157,8 @@ class AssociationHasManyThroughRowScopeTests: GRDBTestCase { } try db.create(table: "child") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId").references("parent") - t.column("grandChildId").references("grandChild") + t.belongsTo("parent") + t.belongsTo("grandChild") } try db.execute(sql: """ INSERT INTO parent (id) VALUES (1); @@ -198,8 +198,8 @@ class AssociationHasManyThroughRowScopeTests: GRDBTestCase { } try db.create(table: "children") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId").references("parents") - t.column("grandChildId").references("grandChildren") + t.belongsTo("parent") + t.belongsTo("grandChild") } try db.execute(sql: """ INSERT INTO parents (id) VALUES (1); @@ -237,8 +237,8 @@ class AssociationHasManyThroughRowScopeTests: GRDBTestCase { } try db.create(table: "child") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId").references("parent") - t.column("grandChildId").references("grandChild") + t.belongsTo("parent") + t.belongsTo("grandChild") } try db.execute(sql: """ INSERT INTO parent (id) VALUES (1); diff --git a/Tests/GRDBTests/AssociationHasManyThroughSQLTests.swift b/Tests/GRDBTests/AssociationHasManyThroughSQLTests.swift index d054a57c2..816e8beac 100644 --- a/Tests/GRDBTests/AssociationHasManyThroughSQLTests.swift +++ b/Tests/GRDBTests/AssociationHasManyThroughSQLTests.swift @@ -26,11 +26,11 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasManyWithTwoSteps( @@ -66,11 +66,11 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") + t.belongsTo("a") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasManyWithTwoSteps( @@ -109,8 +109,8 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") - t.column("aId").references("a") + t.belongsTo("c") + t.belongsTo("a") } try testHasManyWithTwoSteps( @@ -146,11 +146,11 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") + t.belongsTo("a") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasManyWithTwoSteps( @@ -334,13 +334,13 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "child") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("parent") + t.belongsTo("parent") } try db.create(table: "toy") { t in - t.column("childId", .integer).references("child") + t.belongsTo("child") } try db.create(table: "pet") { t in - t.column("childId", .integer).references("child") + t.belongsTo("child") } } @@ -462,15 +462,15 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") + t.belongsTo("a") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try db.create(table: "d") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try testHasManyWithThreeSteps( @@ -521,15 +521,15 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try db.create(table: "d") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasManyWithThreeSteps( @@ -581,12 +581,12 @@ class AssociationHasManyThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") + t.belongsTo("a") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") - t.column("dId").references("d") + t.belongsTo("b") + t.belongsTo("d") } try testHasManyWithThreeSteps( diff --git a/Tests/GRDBTests/AssociationHasOneSQLTests.swift b/Tests/GRDBTests/AssociationHasOneSQLTests.swift index f61c05772..6d7420787 100644 --- a/Tests/GRDBTests/AssociationHasOneSQLTests.swift +++ b/Tests/GRDBTests/AssociationHasOneSQLTests.swift @@ -189,7 +189,7 @@ class AssociationHasOneSQLTests: GRDBTestCase { t.primaryKey("id", .integer) } try db.create(table: "children") { t in - t.column("parentId", .integer).references("parents") + t.belongsTo("parent") } } @@ -299,8 +299,8 @@ class AssociationHasOneSQLTests: GRDBTestCase { t.primaryKey("id", .integer) } try db.create(table: "children") { t in - t.column("parent1Id", .integer).references("parents") - t.column("parent2Id", .integer).references("parents") + t.belongsTo("parent1", inTable: "parents") + t.belongsTo("parent2", inTable: "parents") } } diff --git a/Tests/GRDBTests/AssociationHasOneThroughDecodableRecordTests.swift b/Tests/GRDBTests/AssociationHasOneThroughDecodableRecordTests.swift index dccbce7b4..2a976c262 100644 --- a/Tests/GRDBTests/AssociationHasOneThroughDecodableRecordTests.swift +++ b/Tests/GRDBTests/AssociationHasOneThroughDecodableRecordTests.swift @@ -49,12 +49,12 @@ class AssociationHasOneThroughDecodableRecordTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") t.column("name", .text) } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") t.column("name", .text) } diff --git a/Tests/GRDBTests/AssociationHasOneThroughFetchableRecordTests.swift b/Tests/GRDBTests/AssociationHasOneThroughFetchableRecordTests.swift index ee45837bd..d0a49bfff 100644 --- a/Tests/GRDBTests/AssociationHasOneThroughFetchableRecordTests.swift +++ b/Tests/GRDBTests/AssociationHasOneThroughFetchableRecordTests.swift @@ -86,12 +86,12 @@ class AssociationHasOneThroughFetchableRecordTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") t.column("name", .text) } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") t.column("name", .text) } diff --git a/Tests/GRDBTests/AssociationHasOneThroughRowScopeTests.swift b/Tests/GRDBTests/AssociationHasOneThroughRowScopeTests.swift index 05981b01f..f5138711f 100644 --- a/Tests/GRDBTests/AssociationHasOneThroughRowScopeTests.swift +++ b/Tests/GRDBTests/AssociationHasOneThroughRowScopeTests.swift @@ -35,12 +35,12 @@ class AssociationHasOneThroughRowscopeTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") t.column("name", .text) } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") t.column("name", .text) } diff --git a/Tests/GRDBTests/AssociationHasOneThroughSQLDerivationTests.swift b/Tests/GRDBTests/AssociationHasOneThroughSQLDerivationTests.swift index 630c7aa88..ce9a335e0 100644 --- a/Tests/GRDBTests/AssociationHasOneThroughSQLDerivationTests.swift +++ b/Tests/GRDBTests/AssociationHasOneThroughSQLDerivationTests.swift @@ -38,11 +38,11 @@ class AssociationHasOneThroughSQLDerivationTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } } } diff --git a/Tests/GRDBTests/AssociationHasOneThroughSQLTests.swift b/Tests/GRDBTests/AssociationHasOneThroughSQLTests.swift index 368aadd96..a9521cc5c 100644 --- a/Tests/GRDBTests/AssociationHasOneThroughSQLTests.swift +++ b/Tests/GRDBTests/AssociationHasOneThroughSQLTests.swift @@ -28,11 +28,11 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasOneWithTwoSteps( @@ -68,11 +68,11 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasOneWithTwoSteps( @@ -111,8 +111,8 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") - t.column("aId").references("a") + t.belongsTo("c") + t.belongsTo("a") } try testHasOneWithTwoSteps( @@ -148,11 +148,11 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") + t.belongsTo("a") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasOneWithTwoSteps( @@ -437,15 +437,15 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("dId").references("d") + t.belongsTo("d") } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasOneWithThreeSteps( @@ -494,15 +494,15 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "d") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasOneWithThreeSteps( @@ -554,12 +554,12 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") - t.column("dId").references("d") + t.belongsTo("b") + t.belongsTo("d") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasOneWithThreeSteps( @@ -608,15 +608,15 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try db.create(table: "d") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try testHasOneWithThreeSteps( @@ -668,12 +668,12 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("dId").references("d") + t.belongsTo("d") } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") - t.column("cId").references("c") + t.belongsTo("a") + t.belongsTo("c") } try testHasOneWithThreeSteps( @@ -725,12 +725,12 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "d") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") - t.column("cId").references("c") + t.belongsTo("a") + t.belongsTo("c") } try testHasOneWithThreeSteps( @@ -782,12 +782,12 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") + t.belongsTo("a") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") - t.column("dId").references("d") + t.belongsTo("b") + t.belongsTo("d") } try testHasOneWithThreeSteps( @@ -836,15 +836,15 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("aId").references("a") + t.belongsTo("a") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } try db.create(table: "d") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try testHasOneWithThreeSteps( @@ -1724,19 +1724,19 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase { } try db.create(table: "d") { t in t.autoIncrementedPrimaryKey("id") - t.column("eId").references("e") + t.belongsTo("e") } try db.create(table: "c") { t in t.autoIncrementedPrimaryKey("id") - t.column("dId").references("d") + t.belongsTo("d") } try db.create(table: "b") { t in t.autoIncrementedPrimaryKey("id") - t.column("cId").references("c") + t.belongsTo("c") } try db.create(table: "a") { t in t.autoIncrementedPrimaryKey("id") - t.column("bId").references("b") + t.belongsTo("b") } let associations = [ diff --git a/Tests/GRDBTests/AssociationPrefetchingCodableRecordTests.swift b/Tests/GRDBTests/AssociationPrefetchingCodableRecordTests.swift index f981209ba..7877a5e2d 100644 --- a/Tests/GRDBTests/AssociationPrefetchingCodableRecordTests.swift +++ b/Tests/GRDBTests/AssociationPrefetchingCodableRecordTests.swift @@ -1350,9 +1350,7 @@ class AssociationPrefetchingCodableRecordTests: GRDBTestCase { try dbQueue.write { db in try db.create(table: "employee") { t in t.autoIncrementedPrimaryKey("id") - t.column("managerId", .integer) - .indexed() - .references("employee", onDelete: .restrict) + t.belongsTo("manager", inTable: "employee", onDelete: .restrict) t.column("name", .text) } try db.execute(sql: """ diff --git a/Tests/GRDBTests/CommonTableExpressionTests.swift b/Tests/GRDBTests/CommonTableExpressionTests.swift index c12a52ebe..448b06add 100644 --- a/Tests/GRDBTests/CommonTableExpressionTests.swift +++ b/Tests/GRDBTests/CommonTableExpressionTests.swift @@ -631,11 +631,11 @@ class CommonTableExpressionTests: GRDBTestCase { } try db.create(table: "player") { t in t.autoIncrementedPrimaryKey("id") - t.column("teamId", .integer).references("team") + t.belongsTo("team") } try db.create(table: "award") { t in t.autoIncrementedPrimaryKey("id") - t.column("playerId", .integer).references("player") + t.belongsTo("player") } struct Team: TableRecord { } struct Player: TableRecord { diff --git a/Tests/GRDBTests/DatabaseErrorTests.swift b/Tests/GRDBTests/DatabaseErrorTests.swift index fe7b42448..8bba886ff 100644 --- a/Tests/GRDBTests/DatabaseErrorTests.swift +++ b/Tests/GRDBTests/DatabaseErrorTests.swift @@ -205,7 +205,7 @@ class DatabaseErrorTests: GRDBTestCase { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in try db.create(table: "parents") { $0.column("id", .integer).primaryKey() } - try db.create(table: "children") { $0.column("parentId", .integer).references("parents") } + try db.create(table: "children") { $0.belongsTo("parent") } do { try db.execute(sql: "INSERT INTO children (parentId) VALUES (1)") } catch let error as DatabaseError { @@ -219,7 +219,7 @@ class DatabaseErrorTests: GRDBTestCase { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in try db.create(table: "parents") { $0.column("id", .integer).primaryKey() } - try db.create(table: "children") { $0.column("parentId", .integer).references("parents") } + try db.create(table: "children") { $0.belongsTo("parent") } do { try db.execute(sql: "INSERT INTO children (parentId) VALUES (1)") } catch let error as NSError { diff --git a/Tests/GRDBTests/DerivableRequestTests.swift b/Tests/GRDBTests/DerivableRequestTests.swift index 3d418da97..d5555ee9e 100644 --- a/Tests/GRDBTests/DerivableRequestTests.swift +++ b/Tests/GRDBTests/DerivableRequestTests.swift @@ -50,7 +50,7 @@ private var libraryMigrator: DatabaseMigrator = { } try db.create(table: "book") { t in t.autoIncrementedPrimaryKey("id") - t.column("authorId", .integer).notNull().references("author") + t.belongsTo("author").notNull() t.column("title", .text).notNull() } try db.create(virtualTable: "bookFts4", using: FTS4()) { t in diff --git a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift index 57a2863cf..c4b0c0046 100644 --- a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift +++ b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift @@ -660,7 +660,7 @@ class QueryInterfaceExpressionsTests: GRDBTestCase { try dbQueue.write { db in try db.create(table: "parent") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("parent") + t.belongsTo("parent") } try db.create(table: "child") { t in t.column("childParentId", .integer).references("parent") diff --git a/Tests/GRDBTests/QueryInterfacePromiseTests.swift b/Tests/GRDBTests/QueryInterfacePromiseTests.swift index 1cd1c14de..fc4fb50cf 100644 --- a/Tests/GRDBTests/QueryInterfacePromiseTests.swift +++ b/Tests/GRDBTests/QueryInterfacePromiseTests.swift @@ -14,7 +14,7 @@ class QueryInterfacePromiseTests: GRDBTestCase { try dbWriter.write { db in try db.create(table: "node") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("node") + t.belongsTo("parent", inTable: "node") } } } diff --git a/Tests/GRDBTests/QueryInterfaceRequestTests.swift b/Tests/GRDBTests/QueryInterfaceRequestTests.swift index d3450c6a2..91f032354 100644 --- a/Tests/GRDBTests/QueryInterfaceRequestTests.swift +++ b/Tests/GRDBTests/QueryInterfaceRequestTests.swift @@ -300,7 +300,7 @@ class QueryInterfaceRequestTests: GRDBTestCase { } try db.create(table: "book") { t in t.autoIncrementedPrimaryKey("id") - t.column("authorId", .integer).references("author") + t.belongsTo("author") } try db.execute(sql: """ INSERT INTO author(id, name) VALUES (1, 'Arthur'); diff --git a/Tests/GRDBTests/SQLLiteralTests.swift b/Tests/GRDBTests/SQLLiteralTests.swift index d1c04b7d4..e5ef6272b 100644 --- a/Tests/GRDBTests/SQLLiteralTests.swift +++ b/Tests/GRDBTests/SQLLiteralTests.swift @@ -614,7 +614,7 @@ extension SQLLiteralTests { } try db.create(table: "player") { t in t.autoIncrementedPrimaryKey("id") - t.column("teamId", .integer).references("team") + t.belongsTo("team") t.column("score", .integer) } struct Player: TableRecord { } diff --git a/Tests/GRDBTests/TableRecordDeleteTests.swift b/Tests/GRDBTests/TableRecordDeleteTests.swift index 23df2f131..88e9c8174 100644 --- a/Tests/GRDBTests/TableRecordDeleteTests.swift +++ b/Tests/GRDBTests/TableRecordDeleteTests.swift @@ -382,7 +382,7 @@ class TableRecordDeleteTests: GRDBTestCase { try db.create(table: "player") { t in t.autoIncrementedPrimaryKey("id") - t.column("teamId", .integer).references("team") + t.belongsTo("team") } do { @@ -457,7 +457,7 @@ class TableRecordDeleteTests: GRDBTestCase { try db.create(table: "player") { t in t.autoIncrementedPrimaryKey("id") - t.column("teamId", .integer).references("team") + t.belongsTo("team") } do { diff --git a/Tests/GRDBTests/TableRecordUpdateTests.swift b/Tests/GRDBTests/TableRecordUpdateTests.swift index 31a523708..b5de3fab7 100644 --- a/Tests/GRDBTests/TableRecordUpdateTests.swift +++ b/Tests/GRDBTests/TableRecordUpdateTests.swift @@ -674,7 +674,7 @@ class TableRecordUpdateTests: GRDBTestCase { try db.create(table: "player") { t in t.autoIncrementedPrimaryKey("id") - t.column("teamId", .integer).references("team") + t.belongsTo("team") t.column("score", .integer) } diff --git a/Tests/GRDBTests/ValueObservationQueryInterfaceRequestTests.swift b/Tests/GRDBTests/ValueObservationQueryInterfaceRequestTests.swift index 30317ed65..c11704e34 100644 --- a/Tests/GRDBTests/ValueObservationQueryInterfaceRequestTests.swift +++ b/Tests/GRDBTests/ValueObservationQueryInterfaceRequestTests.swift @@ -26,7 +26,7 @@ class ValueObservationQueryInterfaceRequestTests: GRDBTestCase { } try db.create(table: "child") { t in t.autoIncrementedPrimaryKey("id") - t.column("parentId", .integer).references("parent", onDelete: .cascade) + t.belongsTo("parent", onDelete: .cascade) t.column("name", .text) } }