mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Merge branch 'development'
This commit is contained in:
commit
f3992a034d
9 files changed
+75
-8
No files matched your search
@@ -89,6 +89,12 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
|
||||
|
||||
---
|
||||
|
||||
## 5.22.1
|
||||
|
||||
Released March 22, 2022 • [diff](https://github.com/groue/GRDB.swift/compare/v5.22.0...v5.22.1)
|
||||
|
||||
- **Fixed** a 5.22.0 regression: [#1194](https://github.com/groue/GRDB.swift/issues/1194) ValueObservation could deadlock when the database is configured with a serial target DispatchQueue.
|
||||
|
||||
## 5.22.0
|
||||
|
||||
Released March 22, 2022 • [diff](https://github.com/groue/GRDB.swift/compare/v5.21.0...v5.22.0)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GRDB.swift'
|
||||
s.version = '5.22.0'
|
||||
s.version = '5.22.1'
|
||||
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
|
||||
|
||||
@@ -316,4 +316,17 @@ public struct Configuration {
|
||||
return DispatchQueue(label: label, qos: qos)
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a DispatchQueue which has the quality of service of
|
||||
/// read accesses.
|
||||
///
|
||||
/// The returned queue has no target queue, and won't create deadlocks when
|
||||
/// used synchronously from a database access.
|
||||
func makeDispatchQueue(label: String) -> DispatchQueue {
|
||||
if let targetQueue = targetQueue {
|
||||
return DispatchQueue(label: label, qos: targetQueue.qos)
|
||||
} else {
|
||||
return DispatchQueue(label: label, qos: qos)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ final class ValueConcurrentObserver<Reducer: ValueReducer> {
|
||||
fetch: reducer._fetch)
|
||||
self.notificationCallbacks = NotificationCallbacks(events: events, onChange: onChange)
|
||||
self.reducer = reducer
|
||||
self.reduceQueue = dbPool.configuration.makeReaderDispatchQueue(label: dbPool.configuration.identifier(
|
||||
self.reduceQueue = dbPool.configuration.makeDispatchQueue(label: dbPool.configuration.identifier(
|
||||
defaultLabel: "GRDB",
|
||||
purpose: "ValueObservation"))
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ final class ValueWriteOnlyObserver<Writer: DatabaseWriter, Reducer: ValueReducer
|
||||
fetch: reducer._fetch)
|
||||
self.notificationCallbacks = NotificationCallbacks(events: events, onChange: onChange)
|
||||
self.reducer = reducer
|
||||
self.reduceQueue = writer.configuration.makeReaderDispatchQueue(label: writer.configuration.identifier(
|
||||
self.reduceQueue = writer.configuration.makeDispatchQueue(label: writer.configuration.identifier(
|
||||
defaultLabel: "GRDB",
|
||||
purpose: "ValueObservation"))
|
||||
}
|
||||
|
||||
@@ -538,8 +538,8 @@ ifdef JAZZY
|
||||
--author 'Gwendal Roué' \
|
||||
--author_url https://github.com/groue \
|
||||
--github_url https://github.com/groue/GRDB.swift \
|
||||
--github-file-prefix https://github.com/groue/GRDB.swift/tree/v5.22.0 \
|
||||
--module-version 5.22.0 \
|
||||
--github-file-prefix https://github.com/groue/GRDB.swift/tree/v5.22.1 \
|
||||
--module-version 5.22.1 \
|
||||
--module GRDB \
|
||||
--root-url http://groue.github.io/GRDB.swift/docs/5.22/ \
|
||||
--output Documentation/Reference \
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
---
|
||||
|
||||
**Latest release**: March 22, 2022 • [version 5.22.0](https://github.com/groue/GRDB.swift/tree/v5.22.0) • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md)
|
||||
**Latest release**: March 26, 2022 • [version 5.22.1](https://github.com/groue/GRDB.swift/tree/v5.22.1) • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md)
|
||||
|
||||
**Requirements**: iOS 11.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ • SQLite 3.8.5+ • Swift 5.3+ / Xcode 12+
|
||||
|
||||
| Swift version | GRDB version |
|
||||
| -------------- | ----------------------------------------------------------- |
|
||||
| **Swift 5.3+** | **v5.22.0** |
|
||||
| **Swift 5.3+** | **v5.22.1** |
|
||||
| Swift 5.2 | [v5.12.0](https://github.com/groue/GRDB.swift/tree/v5.12.0) |
|
||||
| Swift 5.1 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
|
||||
| Swift 5 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>5.22.0</string>
|
||||
<string>5.22.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -423,5 +423,53 @@ class ValueObservationPublisherTests : XCTestCase {
|
||||
.runAtTemporaryDatabasePath { try setUp(DatabaseQueue(path: $0)) }
|
||||
.runAtTemporaryDatabasePath { try setUp(DatabasePool(path: $0)) }
|
||||
}
|
||||
|
||||
// MARK: - Regression Tests
|
||||
|
||||
/// Regression test for https://github.com/groue/GRDB.swift/issues/1194
|
||||
func testIssue1194() throws {
|
||||
guard #available(OSX 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
|
||||
throw XCTSkip("Combine is not available")
|
||||
}
|
||||
|
||||
struct Record: Codable, FetchableRecord, PersistableRecord {
|
||||
var id: Int64
|
||||
}
|
||||
|
||||
var configuration = Configuration()
|
||||
configuration.targetQueue = DispatchQueue(label: "crash.test", qos: .userInitiated)
|
||||
|
||||
let database = DatabaseQueue(configuration: configuration)
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("v1") { (db) in
|
||||
try db.create(table: Record.databaseTableName) { (t) in
|
||||
t.autoIncrementedPrimaryKey("id")
|
||||
}
|
||||
}
|
||||
|
||||
try migrator.migrate(database)
|
||||
|
||||
let observation = ValueObservation.tracking { (db) in
|
||||
try Record.fetchCount(db)
|
||||
}
|
||||
|
||||
let exp = expectation(description: "")
|
||||
let cancellable = observation.publisher(in: database, scheduling: .immediate)
|
||||
.map { _ in
|
||||
database.readPublisher { (db) in
|
||||
try Record.fetchCount(db)
|
||||
}
|
||||
}
|
||||
.switchToLatest()
|
||||
.sink(receiveCompletion: { _ in },
|
||||
receiveValue: { (value) in
|
||||
exp.fulfill()
|
||||
})
|
||||
|
||||
withExtendedLifetime(cancellable) {
|
||||
waitForExpectations(timeout: 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user