mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Merge branch 'master' into RowAdapter
Conflicts: TODO.md
This commit is contained in:
commit
3fcbcb9455
4 files changed
+42
-83
No files matched your search
+6
-2
@@ -9,8 +9,12 @@ Release Notes
|
||||
|
||||
```diff
|
||||
final class DatabasePool {
|
||||
- init(path: String, configuration: Configuration = default) throws
|
||||
+ init(path: String, configuration: Configuration = default, maximumReaderCount: Int = default) throws
|
||||
- init(path: String, configuration: Configuration = default, maximumReaderCount: Int = default) throws
|
||||
+ init(path: String, configuration: Configuration = default) throws
|
||||
}
|
||||
struct Configuration {
|
||||
+ var maximumReaderCount: Int = default
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -2935,6 +2935,40 @@ See also [Transactions](#transactions) for more precise handling of transactions
|
||||
FAQ
|
||||
===
|
||||
|
||||
- **Generic parameter 'T' could not be inferred**
|
||||
|
||||
You may get this error when using DatabaseQueue.inDatabase, DatabasePool.read, or DatabasePool.write:
|
||||
|
||||
```swift
|
||||
// Generic parameter 'T' could not be inferred
|
||||
let x = dbQueue.inDatabase { db in
|
||||
let result = String.fetchOne(db, ...)
|
||||
return result
|
||||
}
|
||||
```
|
||||
|
||||
This is a Swift compiler bug (see [SR-1570](https://bugs.swift.org/browse/SR-1570)).
|
||||
|
||||
The general workaround is to explicitly declare the type of the closure result:
|
||||
|
||||
```swift
|
||||
// General Workaround
|
||||
let x = dbQueue.inDatabase { db -> String? in
|
||||
let result = String.fetchOne(db, ...)
|
||||
return result
|
||||
}
|
||||
```
|
||||
|
||||
You can also, when possible, write a single-line closure:
|
||||
|
||||
```swift
|
||||
// Single-line closure workaround:
|
||||
let x = dbQueue.inDatabase { db in
|
||||
String.fetchOne(db, ...)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
- **How do I close a database connection?**
|
||||
|
||||
The short answer is:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- [ ] RowAdapter: document awakeFromFetch for properties initialized from subrows (see RowConvertibleTests:Person.awakeFromFetch)
|
||||
- [ ] maximumReaderCount in Configuration: update README
|
||||
- [ ] FetchedRecordsController: see if we can replace identity comparison function with a function that returns an Equatable value (beware the generics trouble). See if this can help optimize memory use, and use a sortedMerge() algorithm.
|
||||
- [ ] GRDBCipher: remove limitations on iOS or OS X versions
|
||||
- [ ] FetchedRecordsController: take inspiration from https://github.com/jflinter/Dwifft
|
||||
@@ -16,6 +16,7 @@
|
||||
- [ ] MATCH https://www.sqlite.org/lang_expr.html
|
||||
- [ ] REGEXP https://www.sqlite.org/lang_expr.html
|
||||
- [ ] CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END https://www.sqlite.org/lang_expr.html
|
||||
- [ ] RowAdapter: document awakeFromFetch for properties initialized from subrows (see RowConvertibleTests:Person.awakeFromFetch)
|
||||
|
||||
Not sure:
|
||||
|
||||
|
||||
@@ -26,84 +26,4 @@ class DatabaseQueueTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSwiftCompiler() {
|
||||
// Here we test that Swift compiler compiles some various usages of
|
||||
// DatabaseQueue.inDatabase { ... }
|
||||
//
|
||||
// Goal: fix https://github.com/groue/GRDB.swift/issues/54
|
||||
|
||||
// assertNoError {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// try dbQueue.inDatabase { db in
|
||||
// try db.execute("CREATE TABLE foo (id INTEGER PRIMARY KEY")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// assertNoError {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// try dbQueue.inDatabase { db in
|
||||
// try db.execute("CREATE TABLE foo (id INTEGER PRIMARY KEY")
|
||||
// try db.execute("CREATE TABLE bar (id INTEGER PRIMARY KEY")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// assertNoError {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// // TODO: make it compile
|
||||
// try dbQueue.inDatabase { db in
|
||||
// try db.execute("CREATE TABLE foo (id INTEGER PRIMARY KEY")
|
||||
// return 1
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// assertNoError {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// // TODO: make it compile
|
||||
// let x = try dbQueue.inDatabase { db in
|
||||
// try db.execute("CREATE TABLE foo (id INTEGER PRIMARY KEY")
|
||||
// return 1
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// do {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// dbQueue.inDatabase { db in
|
||||
// let x = 1
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// do {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// let x = dbQueue.inDatabase { db in
|
||||
// 1
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// do {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// dbQueue.inDatabase { db in
|
||||
// 1
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// do {
|
||||
// let dbQueue = DatabaseQueue()
|
||||
// // TODO: make it compile
|
||||
// let x = dbQueue.inDatabase { db in
|
||||
// let a = 1
|
||||
// let b = 2
|
||||
// return a + b
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// do {
|
||||
// // TODO: make it compile
|
||||
// dbQueue.inDatabase { db in
|
||||
// let a = 1
|
||||
// let b = 2
|
||||
// return a + b
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user