README.md

This commit is contained in:
Gwendal Roué committed 2016-04-22 04:28:28 +02:00
1 parent 4f344ab1a6
commit 5ccf66bd9b
1 file changed
+12 -12
+12 -12
View File
@@ -615,7 +615,7 @@ Generally speaking, you can extract the type you need, *provided it can be conve
See [Values](#values) for more information on supported types (Bool, Int, String, NSDate, Swift enums, etc.)
- **NULL is converted to nil.**
- **NULL returns nil.**
```swift
let row = Row.fetchOne(db, "SELECT NULL")!
@@ -623,17 +623,6 @@ Generally speaking, you can extract the type you need, *provided it can be conve
row.value(atIndex: 0) as Int // fatal error: could not convert NULL to Int.
```
- **Invalid conversions throw a fatal error.**
```swift
let row = Row.fetchOne(db, "SELECT 'foo'")!
row.value(atIndex: 0) as String // "foo"
row.value(atIndex: 0) as NSDate? // fatal error: could not convert "foo" to NSDate.
row.value(atIndex: 0) as NSDate // fatal error: could not convert "foo" to NSDate.
```
This fatal error can be avoided with the [DatabaseValue.failableValue()](#databasevalue) method.
- **Missing columns return nil.**
```swift
@@ -644,6 +633,17 @@ Generally speaking, you can extract the type you need, *provided it can be conve
You can explicitly check for a column presence with the `hasColumn` method.
- **Invalid conversions throw a fatal error.**
```swift
let row = Row.fetchOne(db, "SELECT 'foo'")!
row.value(atIndex: 0) as String // "foo"
row.value(atIndex: 0) as NSDate? // fatal error: could not convert "foo" to NSDate.
row.value(atIndex: 0) as NSDate // fatal error: could not convert "foo" to NSDate.
```
This fatal error can be avoided with the [DatabaseValue.failableValue()](#databasevalue) method.
- **SQLite has a weak type system, and provides [convenience conversions](https://www.sqlite.org/c3ref/column_blob.html) that can turn Blob to String, String to Int, etc.**
GRDB will sometimes let those conversions go through: