Skip to content

Commit 8ed5ac8

Browse files
authored
Merge pull request #1062 from stephencelis/vacuum
Adding a `vacuum()` fonction to `Connection`
2 parents 31f667f + af48014 commit 8ed5ac8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Sources/SQLite/Core/Connection.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ public final class Connection {
252252
@discardableResult public func run(_ statement: String, _ bindings: [String: Binding?]) throws -> Statement {
253253
return try prepare(statement).run(bindings)
254254
}
255+
256+
// MARK: - VACUUM
257+
258+
/// Run a vacuum on the database
259+
///
260+
/// - Throws: `Result.Error` if query execution fails.
261+
///
262+
/// - Returns: The statement.
263+
@discardableResult public func vacuum() throws -> Statement {
264+
return try run("VACUUM")
265+
}
255266

256267
// MARK: - Scalar
257268

Tests/SQLiteTests/ConnectionTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ class ConnectionTests : SQLiteTestCase {
111111
try! db.run("SELECT * FROM users WHERE admin = $admin", ["$admin": 0])
112112
AssertSQL("SELECT * FROM users WHERE admin = 0", 4)
113113
}
114+
115+
func test_vacuum() {
116+
try! db.vacuum()
117+
}
114118

115119
func test_scalar_preparesRunsAndReturnsScalarValues() {
116120
XCTAssertEqual(0, try! db.scalar("SELECT count(*) FROM users WHERE admin = 0") as? Int64)

0 commit comments

Comments
 (0)