Skip to content

Commit e9b0cc4

Browse files
committed
README updates
1 parent 1a362d4 commit e9b0cc4

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

README.md

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ let path = Bundle.main.path(forResource: "db", ofType: "sqlite3")!
193193
let db = try Connection(path, readonly: true)
194194
```
195195

196-
> _Note:_ Signed applications cannot modify their bundle resources. If you
196+
> [!NOTE]
197+
> Signed applications cannot modify their bundle resources. If you
197198
> bundle a database file with your app for the purpose of bootstrapping, copy
198199
> it to a writable location _before_ establishing a connection (see
199200
> [Read-Write Databases](#read-write-databases), above, for typical, writable
@@ -254,7 +255,8 @@ db.busyHandler({ tries in
254255
})
255256
```
256257

257-
> _Note:_ The default timeout is 0, so if you see `database is locked`
258+
> [!NOTE]
259+
> The default timeout is 0, so if you see `database is locked`
258260
> errors, you may be trying to access the same database simultaneously from
259261
> multiple connections.
260262
@@ -314,7 +316,8 @@ Use optional generics for expressions that can evaluate to `NULL`.
314316
let name = SQLExpression<String?>("name")
315317
```
316318

317-
> _Note:_ The default `SQLExpression` initializer is for [quoted
319+
> [!NOTE]
320+
> The default `SQLExpression` initializer is for [quoted
318321
> identifiers](https://www.sqlite.org/lang_keywords.html) (_i.e._, column
319322
> names). To build a literal SQL expression, use `init(literal:)`.
320323
> <!-- FIXME -->
@@ -359,7 +362,8 @@ try db.run(users.create { t in // CREATE TABLE "users" (
359362
}) // )
360363
```
361364

362-
> _Note:_ `SQLExpression<T>` structures (in this case, the `id` and `email`
365+
> [!NOTE]
366+
> `SQLExpression<T>` structures (in this case, the `id` and `email`
363367
> columns), generate `NOT NULL` constraints automatically, while
364368
> `SQLExpression<T?>` structures (`name`) do not.
365369
@@ -402,7 +406,8 @@ several parameters that map to various column constraints and clauses.
402406
// "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
403407
```
404408

405-
> _Note:_ The `primaryKey` parameter cannot be used alongside
409+
> [!NOTE]
410+
> The `primaryKey` parameter cannot be used alongside
406411
> `references`. If you need to create a column that has a default value
407412
> and is also a primary and/or foreign key, use the `primaryKey` and
408413
> `foreignKey` functions mentioned under
@@ -443,7 +448,8 @@ several parameters that map to various column constraints and clauses.
443448
// "name" TEXT DEFAULT 'Anonymous'
444449
```
445450

446-
> _Note:_ The `defaultValue` parameter cannot be used alongside
451+
> [!NOTE]
452+
> The `defaultValue` parameter cannot be used alongside
447453
> `primaryKey` and `references`. If you need to create a column that has
448454
> a default value and is also a primary and/or foreign key, use the
449455
> `primaryKey` and `foreignKey` functions mentioned under
@@ -473,7 +479,8 @@ several parameters that map to various column constraints and clauses.
473479
// "user_id" INTEGER REFERENCES "users" ("id")
474480
```
475481

476-
> _Note:_ The `references` parameter cannot be used alongside
482+
> [!NOTE]
483+
> The `references` parameter cannot be used alongside
477484
> `primaryKey` and `defaultValue`. If you need to create a column that
478485
> has a default value and is also a primary and/or foreign key, use the
479486
> `primaryKey` and `foreignKey` functions mentioned under
@@ -574,7 +581,8 @@ do {
574581
The [`update`](#updating-rows) and [`delete`](#deleting-rows) functions
575582
follow similar patterns.
576583

577-
> _Note:_ If `insert` is called without any arguments, the statement will run
584+
> [!NOTE]
585+
> If `insert` is called without any arguments, the statement will run
578586
> with a `DEFAULT VALUES` clause. The table must not have any constraints
579587
> that aren’t fulfilled by default values.
580588
>
@@ -836,7 +844,8 @@ let query = users.join(posts, on: user_id == users[id])
836844
Namespacing is achieved by subscripting a [query](#queries) with a [column
837845
expression](#expressions) (_e.g._, `users[id]` above becomes `users.id`).
838846

839-
> _Note:_ We can namespace all of a table’s columns using `*`.
847+
> [!NOTE]
848+
> We can namespace all of a table’s columns using `*`.
840849
>
841850
> ```swift
842851
> let query = users.select(users[*])
@@ -1120,7 +1129,8 @@ let count = try db.scalar(users.filter(name != nil).count)
11201129
// SELECT total("balance") FROM "users"
11211130
```
11221131

1123-
> _Note:_ Expressions can be prefixed with a `DISTINCT` clause by calling the
1132+
> [!NOTE]
1133+
> Expressions can be prefixed with a `DISTINCT` clause by calling the
11241134
> `distinct` computed property.
11251135
>
11261136
> ```swift
@@ -1251,7 +1261,8 @@ try db.transaction {
12511261
// COMMIT TRANSACTION
12521262
```
12531263

1254-
> _Note:_ Transactions run in a serial queue.
1264+
> [!NOTE]
1265+
> Transactions run in a serial queue.
12551266

12561267
## Querying the Schema
12571268

@@ -1355,7 +1366,8 @@ tables](#creating-a-table).
13551366
// ALTER TABLE "users" ADD COLUMN "suffix" TEXT DEFAULT 'SR'
13561367
```
13571368

1358-
> _Note:_ Unlike the [`CREATE TABLE` constraint](#table-constraints),
1369+
> [!NOTE]
1370+
> Unlike the [`CREATE TABLE` constraint](#table-constraints),
13591371
> default values may not be expression structures (including
13601372
> `CURRENT_TIME`, `CURRENT_DATE`, or `CURRENT_TIMESTAMP`).
13611373

@@ -1384,7 +1396,7 @@ tables](#creating-a-table).
13841396

13851397
### SchemaChanger
13861398

1387-
Version 0.14.0 introduces `SchemaChanger`, an alternative API to perform more complex
1399+
The `SchemaChanger` is an alternative API to perform more complex
13881400
migrations such as renaming columns. These operations work with all versions of
13891401
SQLite but use SQL statements such as `ALTER TABLE RENAME COLUMN` when available.
13901402

@@ -1527,7 +1539,8 @@ The `Datatype` must be one of the basic Swift types that values are bridged
15271539
through before serialization and deserialization (see [Building Type-Safe SQL
15281540
](#building-type-safe-sql) for a list of types).
15291541

1530-
> _Note:_ `Binding` is a protocol that SQLiteDB uses internally to
1542+
> [!WARNING]
1543+
> `Binding` is a protocol that SQLiteDB uses internally to
15311544
> directly map SQLite types to Swift types. **Do _not_** conform custom types
15321545
> to the `Binding` protocol.
15331546

@@ -1570,7 +1583,8 @@ extension UIImage: Value {
15701583
}
15711584
```
15721585

1573-
> _Note:_ See the [Archives and Serializations Programming Guide][] for more
1586+
> [!NOTE]
1587+
> See the [Archives and Serializations Programming Guide][] for more
15741588
> information on encoding and decoding custom types.
15751589

15761590

@@ -1711,7 +1725,8 @@ arithmetic, bitwise operations, and concatenation.
17111725
| `\|` | `Int -> Int` | `\|` |
17121726
| `+` | `String -> String` | `\|\|` |
17131727

1714-
> _Note:_ SQLiteDB also defines a bitwise XOR operator, `^`, which
1728+
> [!NOTE]
1729+
> SQLiteDB also defines a bitwise XOR operator, `^`, which
17151730
> expands the expression `lhs ^ rhs` to `~(lhs & rhs) & (lhs | rhs)`.
17161731

17171732

@@ -1728,7 +1743,8 @@ arithmetic, bitwise operations, and concatenation.
17281743
Many of SQLite’s [core functions](https://www.sqlite.org/lang_corefunc.html)
17291744
have been surfaced in and type-audited for SQLiteDB.
17301745

1731-
> _Note:_ SQLiteDB aliases the `??` operator to the `ifnull` function.
1746+
> [!NOTE]
1747+
> SQLiteDB aliases the `??` operator to the `ifnull` function.
17321748
>
17331749
> ```swift
17341750
> name ?? email // ifnull("name", "email")
@@ -1779,7 +1795,8 @@ let typeConformsTo: (SQLExpression<String>, SQLExpression<String>) -> SQLExpress
17791795
)
17801796
```
17811797

1782-
> _Note:_ The optional `deterministic` parameter is an optimization that
1798+
> [!NOTE]
1799+
> The optional `deterministic` parameter is an optimization that
17831800
> causes the function to be created with
17841801
> [`SQLITE_DETERMINISTIC`](https://www.sqlite.org/c3ref/c_deterministic.html).
17851802

@@ -1807,7 +1824,8 @@ let images = attachments.filter(typeConformsTo(UTI, kUTTypeImage))
18071824
// SELECT * FROM "attachments" WHERE "typeConformsTo"("UTI", 'public.image')
18081825
```
18091826

1810-
> _Note:_ The return type of a function must be
1827+
> [!NOTE]
1828+
> The return type of a function must be
18111829
> [a core SQL type](#building-type-safe-sql) or [conform to `Value`](#custom-types).
18121830

18131831
We can create loosely-typed functions by handling an array of raw arguments,
@@ -1828,7 +1846,8 @@ let stmt = try db.prepare("SELECT * FROM attachments WHERE typeConformsTo(UTI, ?
18281846
for row in stmt.bind(kUTTypeImage) { /* ... */ }
18291847
```
18301848

1831-
> _Note:_ Prepared queries can be reused, and long lived prepared queries should be `reset()` after each use. Otherwise, the transaction (either [implicit or explicit](https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions)) will be held open until the query is reset or finalized. This can affect performance. Statements are reset automatically during `deinit`.
1849+
> [!NOTE]
1850+
> Prepared queries can be reused, and long lived prepared queries should be `reset()` after each use. Otherwise, the transaction (either [implicit or explicit](https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions)) will be held open until the query is reset or finalized. This can affect performance. Statements are reset automatically during `deinit`.
18321851
>
18331852
> ```swift
18341853
> someObj.statement = try db.prepare("SELECT * FROM attachments WHERE typeConformsTo(UTI, ?)")

0 commit comments

Comments
 (0)