diff --git a/SQLite/Typed/Query.swift b/SQLite/Typed/Query.swift index e45034ca..8eedf2d5 100644 --- a/SQLite/Typed/Query.swift +++ b/SQLite/Typed/Query.swift @@ -954,8 +954,8 @@ extension Connection { return V.fromDatatypeValue(value) } - public func pluck(query: QueryType) -> Row? { - return try! prepare(query.limit(1, query.clauses.limit?.offset)).generate().next() + public func pluck(query: QueryType) throws -> Row? { + return try prepare(query.limit(1, query.clauses.limit?.offset)).generate().next() } /// Runs an `Insert` query. diff --git a/SQLiteTests/QueryTests.swift b/SQLiteTests/QueryTests.swift index b76da61e..e1ef1344 100644 --- a/SQLiteTests/QueryTests.swift +++ b/SQLiteTests/QueryTests.swift @@ -315,7 +315,7 @@ class QueryIntegrationTests : SQLiteTestCase { func test_pluck() { let rowid = try! db.run(users.insert(email <- "alice@example.com")) - XCTAssertEqual(rowid, db.pluck(users)![id]) + XCTAssertEqual(rowid, try! db.pluck(users)![id]) } func test_insert() {