From 02927106ca7f1cc2eef80e6f321cdd2d7db160ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 12 Apr 2018 14:06:13 +0200 Subject: [PATCH] It looks like documentation wants that DatabaseQueue automatically opens transactions as well... --- README.md | 70 ++++++++----------------------------------------------- 1 file changed, 10 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 6adb6168a..ed37217a8 100644 --- a/README.md +++ b/README.md @@ -1275,7 +1275,16 @@ Grape.fromDatabaseValue(row[0]) // nil **Transactions** are a fundamental concept of SQLite that guarantee [data consistency](https://www.sqlite.org/transactional.html) as well as [proper isolation](https://sqlite.org/isolation.html) between application threads and database connections. -These are all important words for a database expert, but not all developers know them very well. That's why GRDB will sometimes open transactions for you, automatically, as a way to enforce its [concurrency guarantees](#concurrency), and provide maximal security for both your application data and application logic. See the [list of database access methods](#list-of-database-access-methods) for an overview. +These are all important words for a database expert, but not all developers know them very well. That's why GRDB will generally open transactions for you, automatically, as a way to enforce its [concurrency guarantees](#concurrency), and provide maximal security for both your application data and application logic: + +```swift +// BEGIN TRANSACTION +// INSERT INTO players ... +// COMMIT +try dbPool.write { db in + try Player(...).insert(db) +} +``` **Yet some users need to control exactly when transactions take place.** This is an advanced use case, described below. @@ -6224,7 +6233,6 @@ You can catch those errors and wait for [UIApplicationDelegate.applicationProtec - [DatabaseWriter and DatabaseReader Protocols](#databasewriter-and-databasereader-protocols) - [Unsafe Concurrency APIs](#unsafe-concurrency-apis) - [Dealing with External Connections](#dealing-with-external-connections) -- [List of Database Access Methods](#list-of-database-access-methods) ### Guarantees and Rules @@ -6596,64 +6604,6 @@ If you absolutely need multiple connections, then: - [Ask questions](https://github.com/groue/GRDB.swift/issues) -### List of Database Access Methods - -This is the list of database access methods: - -- [DatabaseQueue](#databasequeue-methods) -- [DatabasePool](#databasepool-methods) -- [DatabaseSnapshot](#databasesnapshot-methods) -- [DatabaseReader Protocol](#databasereader-protocol-methods) -- [DatabaseWriter Protocol](#databasewriter-protocol-methods) - - -#### [DatabaseQueue](#database-queues) Methods - -| Method | Opens a Transaction | Notes | -| ------ | ------------------- | ----- | -| `read` | NO | Guaranteed read-only access from SQLite 3.8.0 (iOS 8.2+, macOS 10.10+). | -| `inDatabase` | NO | | -| `inTransaction` | YES | | - - -#### [DatabasePool](#database-pools) Methods - -| Method | Opens a Transaction | Notes | -| ------ | ------------------- | ----- | -| `write` | YES | | -| `writeInTransaction` | YES | | -| `writeWithoutTransaction` | NO | | -| `read` | YES | | -| `readFromCurrentState` | YES | Must be executed from a writing block. Can't be executed from inside a transaction. | -| `makeSnapshot` | YES | Can't be executed from inside a transaction. | - - -#### [DatabaseSnapshot](#database-snapshots) Methods - -| Method | Opens a Transaction | Notes | -| ------ | ------------------- | ----- | -| `read` | YES | | - - -#### [DatabaseReader Protocol](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/DatabaseReader.html) Methods - -| Method | Notes | -| ------ | ----- | -| `read` | | -| `unsafeRead` | | -| `unsafeReentrantRead` | | - - -#### [DatabaseWriter Protocol](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/DatabaseWriter.html) Methods - -| Method | Notes | -| ------ | ----- | -| `write` | | -| `writeWithoutTransaction` | | -| `unsafeReentrantWrite` | | -| `readFromCurrentState` | Must be executed from a writing block. Can't be executed from inside a transaction. | - - ## Performance GRDB is a reasonably fast library, and can deliver quite efficient SQLite access. See [Comparing the Performances of Swift SQLite libraries](https://github.com/groue/GRDB.swift/wiki/Performance) for an overview.