Skip to content

Commit f7d017d

Browse files
committed
1 parent b6941cd commit f7d017d

File tree

8 files changed

+64
-64
lines changed

8 files changed

+64
-64
lines changed

SQLite/Core/Connection.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public final class Connection {
100100
/// - Returns: A new database connection.
101101
public init(_ location: Location = .inMemory, readonly: Bool = false) throws {
102102
let flags = readonly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE
103-
_ = try check(sqlite3_open_v2(location.description, &_handle, flags | SQLITE_OPEN_FULLMUTEX, nil))
103+
try check(sqlite3_open_v2(location.description, &_handle, flags | SQLITE_OPEN_FULLMUTEX, nil))
104104
queue.setSpecific(key: /*Migrator FIXME: Use a variable of type DispatchSpecificKey*/ Connection.queueKey, value: queueContext)
105105
}
106106

@@ -356,14 +356,14 @@ public final class Connection {
356356

357357
fileprivate func transaction(_ begin: String, _ block: @escaping () throws -> Void, _ commit: String, or rollback: String) throws {
358358
return try sync {
359-
_ = try self.run(begin)
359+
try self.run(begin)
360360
do {
361361
try block()
362362
} catch {
363-
_ = try self.run(rollback)
363+
try self.run(rollback)
364364
throw error
365365
}
366-
_ = try self.run(commit)
366+
try self.run(commit)
367367
}
368368
}
369369

@@ -590,7 +590,7 @@ public final class Connection {
590590
let rstr = String(cString: rhs.bindMemory(to: UInt8.self, capacity: 0))
591591
return Int32(Int(block(lstr, rstr).rawValue))
592592
}
593-
_ = try check(sqlite3_create_collation_v2(handle, collation, SQLITE_UTF8, unsafeBitCast(box, to: UnsafeMutableRawPointer.self), { callback, _, lhs, _, rhs in
593+
try check(sqlite3_create_collation_v2(handle, collation, SQLITE_UTF8, unsafeBitCast(box, to: UnsafeMutableRawPointer.self), { callback, _, lhs, _, rhs in
594594
unsafeBitCast(callback, to: Collation.self)(lhs!, rhs!)
595595
}, nil))
596596
collations[collation] = box
@@ -625,7 +625,7 @@ public final class Connection {
625625
return success!
626626
}
627627

628-
func check(_ resultCode: Int32, statement: Statement? = nil) throws -> Int32 {
628+
@discardableResult func check(_ resultCode: Int32, statement: Statement? = nil) throws -> Int32 {
629629
guard let error = Result(errorCode: resultCode, connection: self, statement: statement) else {
630630
return resultCode
631631
}

SQLite/Core/Statement.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class Statement {
3737

3838
init(_ connection: Connection, _ SQL: String) throws {
3939
self.connection = connection
40-
_ = try connection.check(sqlite3_prepare_v2(connection.handle, SQL, -1, &handle, nil))
40+
try connection.check(sqlite3_prepare_v2(connection.handle, SQL, -1, &handle, nil))
4141
}
4242

4343
deinit {
@@ -120,7 +120,7 @@ public final class Statement {
120120
/// - Throws: `Result.Error` if query execution fails.
121121
///
122122
/// - Returns: The statement object (useful for chaining).
123-
public func run(_ bindings: Binding?...) throws -> Statement {
123+
@discardableResult public func run(_ bindings: Binding?...) throws -> Statement {
124124
guard bindings.isEmpty else {
125125
return try run(bindings)
126126
}
@@ -135,7 +135,7 @@ public final class Statement {
135135
/// - Throws: `Result.Error` if query execution fails.
136136
///
137137
/// - Returns: The statement object (useful for chaining).
138-
public func run(_ bindings: [Binding?]) throws -> Statement {
138+
@discardableResult public func run(_ bindings: [Binding?]) throws -> Statement {
139139
return try bind(bindings).run()
140140
}
141141

@@ -145,7 +145,7 @@ public final class Statement {
145145
/// - Throws: `Result.Error` if query execution fails.
146146
///
147147
/// - Returns: The statement object (useful for chaining).
148-
public func run(_ bindings: [String: Binding?]) throws -> Statement {
148+
@discardableResult public func run(_ bindings: [String: Binding?]) throws -> Statement {
149149
return try bind(bindings).run()
150150
}
151151

SQLite/Extensions/FTS4.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ extension Tokenizer : CustomStringConvertible {
141141
extension Connection {
142142

143143
public func registerTokenizer(_ submoduleName: String, next: @escaping (String) -> (String, Range<String.Index>)?) throws {
144-
_ = try check(_SQLiteRegisterTokenizer(handle, Tokenizer.moduleName, submoduleName) { input, offset, length in
144+
try check(_SQLiteRegisterTokenizer(handle, Tokenizer.moduleName, submoduleName) { input, offset, length in
145145
let string = String(cString: input)
146146

147147
guard let (token, range) = next(string) else { return nil }
@@ -178,7 +178,7 @@ open class FTSConfig {
178178

179179
open func columns(_ columns: [Expressible]) -> Self {
180180
for column in columns {
181-
_ = self.column(column)
181+
self.column(column)
182182
}
183183
return self
184184
}
@@ -217,15 +217,15 @@ open class FTSConfig {
217217

218218
func options() -> Options {
219219
var options = Options()
220-
_ = options.append(formatColumnDefinitions())
220+
options.append(formatColumnDefinitions())
221221
if let tokenizer = tokenizer {
222-
_ = options.append("tokenize", value: Expression<Void>(literal: tokenizer.description))
222+
options.append("tokenize", value: Expression<Void>(literal: tokenizer.description))
223223
}
224-
_ = options.appendCommaSeparated("prefix", values:prefixes.sorted().map { String($0) })
224+
options.appendCommaSeparated("prefix", values:prefixes.sorted().map { String($0) })
225225
if isContentless {
226-
_ = options.append("content", value: "")
226+
options.append("content", value: "")
227227
} else if let externalContentSchema = externalContentSchema {
228-
_ = options.append("content", value: externalContentSchema.tableName())
228+
options.append("content", value: externalContentSchema.tableName())
229229
}
230230
return options
231231
}
@@ -238,15 +238,15 @@ open class FTSConfig {
238238
return self
239239
}
240240

241-
mutating func appendCommaSeparated(_ key: String, values: [String]) -> Options {
241+
@discardableResult mutating func appendCommaSeparated(_ key: String, values: [String]) -> Options {
242242
if values.isEmpty {
243243
return self
244244
} else {
245245
return append(key, value: values.joined(separator: ","))
246246
}
247247
}
248248

249-
mutating func append(_ key: String, value: CustomStringConvertible?) -> Options {
249+
@discardableResult mutating func append(_ key: String, value: CustomStringConvertible?) -> Options {
250250
return append(key, value: value?.description)
251251
}
252252

@@ -332,11 +332,11 @@ open class FTS4Config : FTSConfig {
332332
for (column, _) in (columnDefinitions.filter { $0.options.contains(.unindexed) }) {
333333
options.append("notindexed", value: column)
334334
}
335-
_ = options.append("languageid", value: languageId)
336-
_ = options.append("compress", value: compressFunction)
337-
_ = options.append("uncompress", value: uncompressFunction)
338-
_ = options.append("matchinfo", value: matchInfo)
339-
_ = options.append("order", value: order)
335+
options.append("languageid", value: languageId)
336+
options.append("compress", value: compressFunction)
337+
options.append("uncompress", value: uncompressFunction)
338+
options.append("matchinfo", value: matchInfo)
339+
options.append("order", value: order)
340340
return options
341341
}
342342
}

SQLite/Extensions/FTS5.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ open class FTS5Config : FTSConfig {
7777

7878
override func options() -> Options {
7979
var options = super.options()
80-
_ = options.append("content_rowid", value: contentRowId)
80+
options.append("content_rowid", value: contentRowId)
8181
if let columnSize = columnSize {
82-
_ = options.append("columnsize", value: Expression<Int>(value: columnSize))
82+
options.append("columnsize", value: Expression<Int>(value: columnSize))
8383
}
84-
_ = options.append("detail", value: detail)
84+
options.append("detail", value: detail)
8585
return options
8686
}
8787

SQLite/Typed/Query.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ extension Connection {
971971
public func run(_ query: Insert) throws -> Int64 {
972972
let expression = query.expression
973973
return try sync {
974-
_ = try self.run(expression.template, expression.bindings)
974+
try self.run(expression.template, expression.bindings)
975975
return self.lastInsertRowid!
976976
}
977977
}
@@ -987,7 +987,7 @@ extension Connection {
987987
public func run(_ query: Update) throws -> Int {
988988
let expression = query.expression
989989
return try sync {
990-
_ = try self.run(expression.template, expression.bindings)
990+
try self.run(expression.template, expression.bindings)
991991
return self.changes
992992
}
993993
}
@@ -1002,7 +1002,7 @@ extension Connection {
10021002
public func run(_ query: Delete) throws -> Int {
10031003
let expression = query.expression
10041004
return try sync {
1005-
_ = try self.run(expression.template, expression.bindings)
1005+
try self.run(expression.template, expression.bindings)
10061006
return self.changes
10071007
}
10081008
}

SQLiteTests/ConnectionTests.swift

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ConnectionTests : SQLiteTestCase {
4848
}
4949

5050
func test_lastInsertRowid_returnsLastIdAfterInserts() {
51-
_ = try! InsertUser("alice")
51+
try! InsertUser("alice")
5252
XCTAssertEqual(1, db.lastInsertRowid!)
5353
}
5454

@@ -57,17 +57,17 @@ class ConnectionTests : SQLiteTestCase {
5757
}
5858

5959
func test_changes_returnsNumberOfChanges() {
60-
_ = try! InsertUser("alice")
60+
try! InsertUser("alice")
6161
XCTAssertEqual(1, db.changes)
62-
_ = try! InsertUser("betsy")
62+
try! InsertUser("betsy")
6363
XCTAssertEqual(1, db.changes)
6464
}
6565

6666
func test_totalChanges_returnsTotalNumberOfChanges() {
6767
XCTAssertEqual(0, db.totalChanges)
68-
_ = try! InsertUser("alice")
68+
try! InsertUser("alice")
6969
XCTAssertEqual(1, db.totalChanges)
70-
_ = try! InsertUser("betsy")
70+
try! InsertUser("betsy")
7171
XCTAssertEqual(2, db.totalChanges)
7272
}
7373

@@ -79,10 +79,10 @@ class ConnectionTests : SQLiteTestCase {
7979
}
8080

8181
func test_run_preparesRunsAndReturnsStatements() {
82-
_ = try! db.run("SELECT * FROM users WHERE admin = 0")
83-
_ = try! db.run("SELECT * FROM users WHERE admin = ?", 0)
84-
_ = try! db.run("SELECT * FROM users WHERE admin = ?", [0])
85-
_ = try! db.run("SELECT * FROM users WHERE admin = $admin", ["$admin": 0])
82+
try! db.run("SELECT * FROM users WHERE admin = 0")
83+
try! db.run("SELECT * FROM users WHERE admin = ?", 0)
84+
try! db.run("SELECT * FROM users WHERE admin = ?", [0])
85+
try! db.run("SELECT * FROM users WHERE admin = $admin", ["$admin": 0])
8686
AssertSQL("SELECT * FROM users WHERE admin = 0", 4)
8787
}
8888

@@ -116,7 +116,7 @@ class ConnectionTests : SQLiteTestCase {
116116
let stmt = try! db.prepare("INSERT INTO users (email) VALUES (?)", "alice@example.com")
117117

118118
try! db.transaction {
119-
_ = try stmt.run()
119+
try stmt.run()
120120
}
121121

122122
AssertSQL("BEGIN DEFERRED TRANSACTION")
@@ -130,8 +130,8 @@ class ConnectionTests : SQLiteTestCase {
130130

131131
do {
132132
try db.transaction {
133-
_ = try stmt.run()
134-
_ = try stmt.run()
133+
try stmt.run()
134+
try stmt.run()
135135
}
136136
} catch {
137137
}
@@ -147,7 +147,7 @@ class ConnectionTests : SQLiteTestCase {
147147

148148
try! db.savepoint("1") {
149149
try db.savepoint("2") {
150-
_ = try db.run("INSERT INTO users (email) VALUES (?)", "alice@example.com")
150+
try db.run("INSERT INTO users (email) VALUES (?)", "alice@example.com")
151151
}
152152
}
153153

@@ -167,14 +167,14 @@ class ConnectionTests : SQLiteTestCase {
167167
do {
168168
try db.savepoint("1") {
169169
try db.savepoint("2") {
170-
_ = try stmt.run()
171-
_ = try stmt.run()
172-
_ = try stmt.run()
170+
try stmt.run()
171+
try stmt.run()
172+
try stmt.run()
173173
}
174174
try db.savepoint("2") {
175-
_ = try stmt.run()
176-
_ = try stmt.run()
177-
_ = try stmt.run()
175+
try stmt.run()
176+
try stmt.run()
177+
try stmt.run()
178178
}
179179
}
180180
} catch {
@@ -198,12 +198,12 @@ class ConnectionTests : SQLiteTestCase {
198198
XCTAssertEqual(1, rowid)
199199
done()
200200
}
201-
_ = try! InsertUser("alice")
201+
try! InsertUser("alice")
202202
}
203203
}
204204

205205
func test_updateHook_setsUpdateHook_withUpdate() {
206-
_ = try! InsertUser("alice")
206+
try! InsertUser("alice")
207207
async { done in
208208
db.updateHook { operation, db, table, rowid in
209209
XCTAssertEqual(Connection.Operation.update, operation)
@@ -212,12 +212,12 @@ class ConnectionTests : SQLiteTestCase {
212212
XCTAssertEqual(1, rowid)
213213
done()
214214
}
215-
_ = try! db.run("UPDATE users SET email = 'alice@example.com'")
215+
try! db.run("UPDATE users SET email = 'alice@example.com'")
216216
}
217217
}
218218

219219
func test_updateHook_setsUpdateHook_withDelete() {
220-
_ = try! InsertUser("alice")
220+
try! InsertUser("alice")
221221
async { done in
222222
db.updateHook { operation, db, table, rowid in
223223
XCTAssertEqual(Connection.Operation.delete, operation)
@@ -226,7 +226,7 @@ class ConnectionTests : SQLiteTestCase {
226226
XCTAssertEqual(1, rowid)
227227
done()
228228
}
229-
_ = try! db.run("DELETE FROM users WHERE id = 1")
229+
try! db.run("DELETE FROM users WHERE id = 1")
230230
}
231231
}
232232

@@ -236,7 +236,7 @@ class ConnectionTests : SQLiteTestCase {
236236
done()
237237
}
238238
try! db.transaction {
239-
_ = try self.InsertUser("alice")
239+
try self.InsertUser("alice")
240240
}
241241
XCTAssertEqual(1, try! db.scalar("SELECT count(*) FROM users") as? Int64)
242242
}
@@ -247,8 +247,8 @@ class ConnectionTests : SQLiteTestCase {
247247
db.rollbackHook(done)
248248
do {
249249
try db.transaction {
250-
_ = try self.InsertUser("alice")
251-
_ = try self.InsertUser("alice") // throw
250+
try self.InsertUser("alice")
251+
try self.InsertUser("alice") // throw
252252
}
253253
} catch {
254254
}
@@ -264,7 +264,7 @@ class ConnectionTests : SQLiteTestCase {
264264
db.rollbackHook(done)
265265
do {
266266
try db.transaction {
267-
_ = try self.InsertUser("alice")
267+
try self.InsertUser("alice")
268268
}
269269
} catch {
270270
}
@@ -308,7 +308,7 @@ class ConnectionTests : SQLiteTestCase {
308308
}
309309

310310
let stmt = try! db.prepare("SELECT *, sleep(?) FROM users", 0.1)
311-
_ = try! stmt.run()
311+
try! stmt.run()
312312

313313
_ = DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background).asyncAfter(deadline: DispatchTime.now() + Double(Int64(10 * NSEC_PER_MSEC)) / Double(NSEC_PER_SEC), execute: db.interrupt)
314314
AssertThrows(try stmt.run())

SQLiteTests/FTS4Tests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ class FTS4IntegrationTests : SQLiteTestCase {
198198
return (token as String, string.range(of: input as String)!)
199199
}
200200

201-
_ = try! db.run(emails.create(.FTS4([subject, body], tokenize: .Custom(tokenizerName))))
201+
try! db.run(emails.create(.FTS4([subject, body], tokenize: .Custom(tokenizerName))))
202202
AssertSQL("CREATE VIRTUAL TABLE \"emails\" USING fts4(\"subject\", \"body\", tokenize=\"SQLite.swift\" \"tokenizer\")")
203203

204-
_ = try! db.run(emails.insert(subject <- "Aún más cáfe!"))
204+
try! db.run(emails.insert(subject <- "Aún más cáfe!"))
205205
XCTAssertEqual(1, try! db.scalar(emails.filter(emails.match("aun")).count))
206206
}
207207
#endif

0 commit comments

Comments
 (0)