From a681ccf2b9e58a798e951ab4bb24a667eb9298e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 20 Feb 2021 11:53:27 +0100 Subject: [PATCH] Fix: DatabaseQueue.read is throws, not rethrows --- CHANGELOG.md | 2 ++ GRDB/Core/DatabaseQueue.swift | 2 +- Tests/GRDBTests/DatabaseQueueTests.swift | 4 ++-- Tests/GRDBTests/DatabaseTests.swift | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4efb9bb87..e0b29f5fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,8 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: The [Common Table Expressions Guide](Documentation/CommonTableExpressions.md) was updated accordingly. +- **Fixed**: `DatabaseQueue.read` is now declared `throws` instead of `rethrows`. + ## 5.4.0 Released February 15, 2021 • [diff](https://github.com/groue/GRDB.swift/compare/v5.3.0...v5.4.0) diff --git a/GRDB/Core/DatabaseQueue.swift b/GRDB/Core/DatabaseQueue.swift index 2bc1fab86..b9f622dbc 100644 --- a/GRDB/Core/DatabaseQueue.swift +++ b/GRDB/Core/DatabaseQueue.swift @@ -190,7 +190,7 @@ extension DatabaseQueue { /// /// - parameter block: A block that accesses the database. /// - throws: The error thrown by the block. - public func read(_ block: (Database) throws -> T) rethrows -> T { + public func read(_ block: (Database) throws -> T) throws -> T { try writer.sync { db in try db.readOnly { try block(db) } } diff --git a/Tests/GRDBTests/DatabaseQueueTests.swift b/Tests/GRDBTests/DatabaseQueueTests.swift index 6625a718b..3a14dc58c 100644 --- a/Tests/GRDBTests/DatabaseQueueTests.swift +++ b/Tests/GRDBTests/DatabaseQueueTests.swift @@ -135,7 +135,7 @@ class DatabaseQueueTests: GRDBTestCase { try dbQueue.write { _ in dispatchPrecondition(condition: .onQueue(targetQueue)) } - dbQueue.read { _ in + try dbQueue.read { _ in dispatchPrecondition(condition: .onQueue(targetQueue)) } } @@ -185,7 +185,7 @@ class DatabaseQueueTests: GRDBTestCase { try dbQueue.write { _ in dispatchPrecondition(condition: .onQueue(targetQueue)) } - dbQueue.read { _ in + try dbQueue.read { _ in dispatchPrecondition(condition: .onQueue(targetQueue)) } } diff --git a/Tests/GRDBTests/DatabaseTests.swift b/Tests/GRDBTests/DatabaseTests.swift index 4179a2860..21e91548f 100644 --- a/Tests/GRDBTests/DatabaseTests.swift +++ b/Tests/GRDBTests/DatabaseTests.swift @@ -378,7 +378,7 @@ class DatabaseTests : GRDBTestCase { func testMaximumStatementArgumentCount() throws { let dbQueue = try makeDatabaseQueue() - let count = dbQueue.read { $0.maximumStatementArgumentCount } + let count = try dbQueue.read { $0.maximumStatementArgumentCount } // 999 should be safe: https://www.sqlite.org/limits.html XCTAssertGreaterThanOrEqual(count, 999) }