README.md

This commit is contained in:
Gwendal Roué committed 2015-07-04 16:09:48 +02:00
1 parent 4a35f5b1c6
commit a6ca8b661e
1 file changed
+18
+18
View File
@@ -325,6 +325,24 @@ try dbQueue.inDatabase { db in
}
```
Note that the `Database.selectStatement()` function is the **only** function of GRDB.swift that may throw an error when building a SELECT statement. All other fetching functions prefer dying in a loud and verbose crash when given an invalid SELECT statements.
Compare:
```swift
// fatal error: SQLite error 1 with statement `SELECT foo FROM bar`:
// no such table: bar
db.fetchAllRows("SELECT foo FROM bar")
do {
let statement = try db.selectStatement("SELECT foo FROM bar")
} catch let error as SQLiteError {
error.code // 1: the SQLite error code
error.message // "no such table: bar": the eventual SQLite message
error.sql // "SELECT foo FROM bar": the eventual erroneous SQL query
}
```
## Migrations