Skip to content

Commit 1efaf8b

Browse files
committed
Change ALTER TABLE RENAME TO signature
This is mainly important for migrations, so let's take the old table name as a string and pass in a query as the new table, instead. Signed-off-by: Stephen Celis <[email protected]>
1 parent 992bb38 commit 1efaf8b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

SQLite Tests/SchemaTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ class SchemaTests: XCTestCase {
264264

265265
func test_alterTable_renamesTable() {
266266
CreateUsersTable(db)
267-
ExpectExecution(db, "ALTER TABLE \"users\" RENAME TO \"people\"", db.rename(table: users, to: "people") )
267+
let people = db["people"]
268+
ExpectExecution(db, "ALTER TABLE \"users\" RENAME TO \"people\"", db.rename(table: "users", to: people) )
268269
}
269270

270271
func test_alterTable_addsNotNullColumn() {

SQLite/Schema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public extension Database {
4343
return run("\(create) AS \(expression.SQL)", expression.bindings)
4444
}
4545
46-
public func rename(#table: Query, to tableName: String) -> Statement {
47-
return run("ALTER TABLE \(table.tableName.unaliased.SQL) RENAME TO \(quote(identifier: tableName))")
46+
public func rename(table tableName: String, to table: Query) -> Statement {
47+
return run("ALTER TABLE \(quote(identifier: tableName)) RENAME TO \(table.tableName.unaliased.SQL)")
4848
}
4949
5050
public func alter<V: Value>(

0 commit comments

Comments
 (0)