Skip to content

Commit 403077f

Browse files
committed
Fix the error handling in Query.pluck()
1 parent 9e71e30 commit 403077f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

SQLite/Typed/Query.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,10 @@ extension Connection {
955955
}
956956

957957
public func pluck(query: QueryType) -> Row? {
958-
return try! prepare(query.limit(1, query.clauses.limit?.offset)).generate().next()
958+
guard let rows = try? prepare(query.limit(1, query.clauses.limit?.offset)) else {
959+
return nil
960+
}
961+
return rows.generate().next()
959962
}
960963

961964
/// Runs an `Insert` query.

0 commit comments

Comments
 (0)