Skip to content

Commit 25bd063

Browse files
committed
Better API, test
1 parent 3def7d6 commit 25bd063

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Sources/SQLite/Schema/SchemaChanger.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ public class SchemaChanger: CustomStringConvertible {
224224
}
225225

226226
// Runs arbitrary SQL. Should only be used if no predefined operations exist.
227-
public func run(sql: String) throws {
228-
try connection.run(sql)
227+
@discardableResult
228+
public func run(_ sql: String, _ bindings: Binding?...) throws -> Statement {
229+
return try connection.run(sql, bindings)
229230
}
230231

231232
private func run(table: String, operation: Operation) throws {

Tests/SQLiteTests/Schema/SchemaChangerTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,9 @@ class SchemaChangerTests: SQLiteTestCase {
375375
references: .init(fromColumn: "foo_id", toTable: "foo", toColumn: "id", onUpdate: nil, onDelete: nil))
376376
], barColumns)
377377
}
378+
379+
func test_run_arbitrary_sql() throws {
380+
try schemaChanger.run("DROP TABLE users")
381+
XCTAssertEqual(0, try schema.objectDefinitions(name: "users", type: .table).count)
382+
}
378383
}

0 commit comments

Comments
 (0)