mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Merge remote-tracking branch 'origin/master' into GRDB3
This commit is contained in:
commit
92f037eb74
2 files changed
+13
-13
No files matched your search
@@ -143,11 +143,11 @@ Database queues look a lot like FMDB's [FMDatabaseQueue](https://github.com/ccgu
|
||||
|
||||
### Strong and clear multi-threading guarantees
|
||||
|
||||
I'd like to compare GRDB's handling of concurrency with other libraries. To be as clear as possible, we'll identity a few threats, or potential sources of bugs, and wonder if those are handled by the library, or left to the host application.
|
||||
I'd like to compare GRDB's handling of concurrency with other libraries. To be as clear as possible, we'll identify a few threats, or potential sources of bugs, and wonder if those are handled by the library, or left to the host application.
|
||||
|
||||
The more threats are handled by the application, the more skilled and careful a developer has to be in order to avoid them.
|
||||
|
||||
- **Concurrent writes**: Two threads want to write in the database as the same time. SQLite does not allow that.
|
||||
- **Concurrent writes**: Two threads want to write in the database at the same time. SQLite does not allow that.
|
||||
- **Isolation troubles**: As two database queries run one after the other, a concurrent thread sneaks in and modifies the database in between. The two queries can thus perform inconsistent fetches or updates, unless they are properly isolated. Lack of isolation may display funny values on the screen, trigger a relational constraint error, or silently corrupt the database content.
|
||||
- **Conflicts**: The same piece of data is both edited by the application user, and refreshed from a network operation. What will eventually be stored in the database? Can any conflict be noticed?
|
||||
- **Blocked UI**: Can it happen that the UI is blocked because the main thread has to wait for a background thread to release a lock on the database?
|
||||
|
||||
@@ -2223,7 +2223,7 @@ protocol FetchableRecord {
|
||||
}
|
||||
```
|
||||
|
||||
**To use FetchableRecord**, subclass the [Record](#record-class) class, or adopt it explicitely. For example:
|
||||
**To use FetchableRecord**, subclass the [Record](#record-class) class, or adopt it explicitly. For example:
|
||||
|
||||
```swift
|
||||
struct Place {
|
||||
@@ -2370,7 +2370,7 @@ The `encode(to:)` method defines which [values](#values) (Bool, Int, String, Dat
|
||||
|
||||
The optional `didInsert` method lets the adopting type store its rowID after successful insertion. If your table has an INTEGER PRIMARY KEY column, you are likely to define this method. Otherwise, you can safely ignore it. It is called from a protected dispatch queue, and serialized with all database updates.
|
||||
|
||||
**To use those protocols**, subclass the [Record](#record-class) class, or adopt one of them explicitely. For example:
|
||||
**To use those protocols**, subclass the [Record](#record-class) class, or adopt one of them explicitly. For example:
|
||||
|
||||
```swift
|
||||
extension Place : MutablePersistableRecord {
|
||||
@@ -3292,7 +3292,7 @@ try db.create(table: "example", temporary: true, ifNotExists: true) { t in
|
||||
// a,
|
||||
// name TEXT,
|
||||
// creationDate DATETIME,
|
||||
try db.create(table: "example") { t in ... }
|
||||
try db.create(table: "example") { t in
|
||||
t.column("a")
|
||||
t.column("name", .text)
|
||||
t.column("creationDate", .datetime)
|
||||
@@ -3355,7 +3355,7 @@ Other **table constraints** can involve several columns:
|
||||
t.uniqueKey(["a", "b"], onConfict: .replace)
|
||||
|
||||
// FOREIGN KEY (a, b) REFERENCES parents(c, d),
|
||||
t.foreignKey(["a", "b"], references: "parent")
|
||||
t.foreignKey(["a", "b"], references: "parents")
|
||||
|
||||
// CHECK (a + b < 10),
|
||||
t.check(Column("a") + Column("b") < 10)
|
||||
@@ -3742,7 +3742,7 @@ Feed [requests](#requests) with SQL expressions built from your Swift code:
|
||||
Player.filter(emailColumn.like("%@example.com"))
|
||||
```
|
||||
|
||||
> :point_up: **Note**: the SQLite LIKE operator is case-unsensitive but not Unicode-aware. For example, the expression `'a' LIKE 'A'` is true but `'æ' LIKE 'Æ'` is false.
|
||||
> :point_up: **Note**: the SQLite LIKE operator is case-insensitive but not Unicode-aware. For example, the expression `'a' LIKE 'A'` is true but `'æ' LIKE 'Æ'` is false.
|
||||
|
||||
- `MATCH`
|
||||
|
||||
@@ -5450,7 +5450,7 @@ func startMonitoring(_ db: Database, region: CLRegion) throws {
|
||||
}
|
||||
```
|
||||
|
||||
The method above won't trigger the location manager if the transaction is eventually rollbacked (explicitely, or because of an error), as in the sample code below:
|
||||
The method above won't trigger the location manager if the transaction is eventually rollbacked (explicitly, or because of an error), as in the sample code below:
|
||||
|
||||
```swift
|
||||
try dbQueue.inTransaction { db in
|
||||
@@ -5748,7 +5748,7 @@ See also [RxGRDB](http://github.com/RxSwiftCommunity/RxGRDB), an [RxSwift](https
|
||||
- [The Changes Notifications](#the-changes-notifications)
|
||||
- [Modifying the Fetch Request](#modifying-the-fetch-request)
|
||||
- [Table and Collection Views](#table-and-collection-views)
|
||||
- [Implementing the Table View Datasource Methods](#implementing-the-table-view-datasource methods)
|
||||
- [Implementing the Table View Datasource Methods](#implementing-the-table-view-datasource-methods)
|
||||
- [Implementing Table View Updates](#implementing-table-view-updates)
|
||||
- [FetchedRecordsController Concurrency](#fetchedrecordscontroller-concurrency)
|
||||
|
||||
@@ -6474,7 +6474,7 @@ GRDB extends SQLite with [SQL functions](#custom-sql-functions-and-aggregates) t
|
||||
|
||||
```swift
|
||||
// "JÉRÔME"
|
||||
let uppercase = DatabaseFunction.uppercase
|
||||
let uppercased = DatabaseFunction.uppercase
|
||||
try String.fetchOne(db, "SELECT \(uppercased.name)('Jérôme')")
|
||||
```
|
||||
|
||||
@@ -6559,7 +6559,7 @@ This method blocks the current thread until all current database accesses are co
|
||||
|
||||
```
|
||||
let dbQueue = try DatabaseQueue(...)
|
||||
dbQueue.setupMemoryManagement(in: UIApplication.sharedApplication())
|
||||
dbQueue.setupMemoryManagement(in: UIApplication.shared)
|
||||
```
|
||||
|
||||
|
||||
@@ -6920,7 +6920,7 @@ DatabaseWriter and DatabaseReader fuel, for example:
|
||||
}
|
||||
```
|
||||
|
||||
When used on a datase queue, the closure argument is allowed to write in the database.
|
||||
When used on a database queue, the closure argument is allowed to write in the database.
|
||||
|
||||
- **`unsafeReentrantRead`**
|
||||
|
||||
@@ -7384,7 +7384,7 @@ Sample Code
|
||||
**Thanks**
|
||||
|
||||
- [Pierlis](http://pierlis.com), where we write great software.
|
||||
- [Vladimir Babin](https://github.com/Chiliec), [Darren Clark](https://github.com/darrenclark), [Pascal Edmond](https://github.com/pakko972), [Andrey Fidrya](https://github.com/zmeyc), [Cristian Filipov](https://github.com/cfilipov), [Matt Greenfield](https://github.com/sobri909), [David Hart](https://github.com/hartbit), [Brad Lindsay](https://github.com/bfad), [@peter-ss](https://github.com/peter-ss), [Pierre-Loïc Raynaud](https://github.com/pierlo), [Stefano Rodriguez](https://github.com/sroddy) [Steven Schveighoffer](https://github.com/schveiguy), [@swiftlyfalling](https://github.com/swiftlyfalling), and [Kevin Wooten](https://github.com/kdubb) for their contributions, help, and feedback on GRDB.
|
||||
- [Vladimir Babin](https://github.com/Chiliec), [Darren Clark](https://github.com/darrenclark), [Pascal Edmond](https://github.com/pakko972), [Andrey Fidrya](https://github.com/zmeyc), [Cristian Filipov](https://github.com/cfilipov), [Matt Greenfield](https://github.com/sobri909), [David Hart](https://github.com/hartbit), [@kluufger](https://github.com/kluufger), [Brad Lindsay](https://github.com/bfad), [@peter-ss](https://github.com/peter-ss), [Pierre-Loïc Raynaud](https://github.com/pierlo), [Stefano Rodriguez](https://github.com/sroddy), [Steven Schveighoffer](https://github.com/schveiguy), [@swiftlyfalling](https://github.com/swiftlyfalling), and [Kevin Wooten](https://github.com/kdubb) for their contributions, help, and feedback on GRDB.
|
||||
- [@aymerick](https://github.com/aymerick) and [Mathieu "Kali" Poumeyrol](https://github.com/kali) because SQL.
|
||||
- [ccgus/fmdb](https://github.com/ccgus/fmdb) for its excellency.
|
||||
|
||||
|
||||
Reference in new issue
Block a user