README.md

This commit is contained in:
Gwendal Roué committed 2015-09-24 04:56:23 +02:00
1 parent f064706f05
commit d9ce97f0cf
1 file changed
+5 -1
+5 -1
View File
@@ -251,6 +251,7 @@ Row.fetch(db, "SELECT * FROM persons WHERE name = ?", arguments: ["Arthur"])
Row.fetch(db, "SELECT * FROM persons WHERE name = :name", arguments: ["name": "Arthur"])
```
**Row sequences grant direct access to SQLite**, and are generally faster than row arrays. Yet:
- Don't consume row sequences outside of a database queue. Extract arrays instead:
@@ -263,7 +264,9 @@ Row.fetch(db, "SELECT * FROM persons WHERE name = :name", arguments: ["name": "A
for row in rows { ... } // OK
```
- Fetched rows are reused during the sequence iteration: make sure you make a copy whenever you extract a row for later use: `row.copy()`.
- Fetched rows are reused during the sequence iteration: don't wrap a row sequence in an array with `Array(rows)` or `rows.filter { ... }` since you would not get the distinct rows you expect. Use `Row.fetchAll(...)` instead.
- For the same reason, make sure you make a copy whenever you extract a row for later use: `row.copy()`.
**Read row values** by index or column name:
@@ -299,6 +302,7 @@ row.value(...) as! Int // NO NO NO DON'T DO THAT!
row.value(...) as? Int // NO NO NO DON'T DO THAT!
```
##### Rows as Dictionaries
The `row.value(named:)` and `row.value(atIndex:)` methods above require that you know the row structure: which columns are available, in which order.