Skip to content

Commit 137788e

Browse files
committed
Named param for rename/drop
1 parent 0f6c3e3 commit 137788e

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Documentation/Index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ We can rename columns with the help of the `SchemaChanger` class:
14901490
```swift
14911491
let schemaChanger = SchemaChanger(connection: db)
14921492
try schemaChanger.alter(table: "users") { table in
1493-
table.rename("old_name", to: "new_name")
1493+
table.rename(column: "old_name", to: "new_name")
14941494
}
14951495
```
14961496

@@ -1499,7 +1499,7 @@ try schemaChanger.alter(table: "users") { table in
14991499
```swift
15001500
let schemaChanger = SchemaChanger(connection: db)
15011501
try schemaChanger.alter(table: "users") { table in
1502-
table.drop("column")
1502+
table.drop(column: "email")
15031503
}
15041504
```
15051505

Sources/SQLite/Schema/SchemaChanger.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public class SchemaChanger: CustomStringConvertible {
9999
operations.append(.addColumn(column))
100100
}
101101

102-
public func drop(_ column: String) {
102+
public func drop(column: String) {
103103
operations.append(.dropColumn(column))
104104
}
105105

106-
public func rename(_ column: String, to: String) {
106+
public func rename(column: String, to: String) {
107107
operations.append(.renameColumn(column, to))
108108
}
109109
}

Tests/SQLiteTests/Schema/SchemaChangerTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SchemaChangerTests: SQLiteTestCase {
5353

5454
func test_drop_column() throws {
5555
try schemaChanger.alter(table: "users") { table in
56-
table.drop("age")
56+
table.drop(column: "age")
5757
}
5858
let columns = try schema.columnDefinitions(table: "users").map(\.name)
5959
XCTAssertFalse(columns.contains("age"))
@@ -63,15 +63,15 @@ class SchemaChangerTests: SQLiteTestCase {
6363
schemaChanger = .init(connection: db, version: .init(major: 3, minor: 24)) // DROP COLUMN introduced in 3.35.0
6464

6565
try schemaChanger.alter(table: "users") { table in
66-
table.drop("age")
66+
table.drop(column: "age")
6767
}
6868
let columns = try schema.columnDefinitions(table: "users").map(\.name)
6969
XCTAssertFalse(columns.contains("age"))
7070
}
7171

7272
func test_rename_column() throws {
7373
try schemaChanger.alter(table: "users") { table in
74-
table.rename("age", to: "age2")
74+
table.rename(column: "age", to: "age2")
7575
}
7676

7777
let columns = try schema.columnDefinitions(table: "users").map(\.name)
@@ -83,7 +83,7 @@ class SchemaChangerTests: SQLiteTestCase {
8383
schemaChanger = .init(connection: db, version: .init(major: 3, minor: 24)) // RENAME COLUMN introduced in 3.25.0
8484

8585
try schemaChanger.alter(table: "users") { table in
86-
table.rename("age", to: "age2")
86+
table.rename(column: "age", to: "age2")
8787
}
8888

8989
let columns = try schema.columnDefinitions(table: "users").map(\.name)

0 commit comments

Comments
 (0)