Skip to content

Commit 2ad1f37

Browse files
committed
Documentation for cast function
1 parent 32642d5 commit 2ad1f37

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Documentation/AssociationsBasics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2661,7 +2661,7 @@ Aggregates can be modified and combined with Swift operators:
26612661
let request = Team.annotated(with: Team.players.min(Column("score")) ?? 0)
26622662
```
26632663

2664-
- SQL functions `ABS` and `LENGTH` are available as the `abs` and `length` Swift functions:
2664+
- SQL functions `ABS`, `CAST`, and `LENGTH` are available as the `abs`, `cast`, and `length` Swift functions:
26652665

26662666
<details>
26672667
<summary>SQL</summary>

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4291,6 +4291,17 @@ GRDB comes with a Swift version of many SQLite [built-in functions](https://sqli
42914291

42924292
For more information about the functions `dateTime` and `julianDay`, see [Date And Time Functions](https://www.sqlite.org/lang_datefunc.html).
42934293

4294+
- `CAST`
4295+
4296+
Use the `cast` Swift function:
4297+
4298+
```swift
4299+
// SELECT (CAST(wins AS REAL) / games) AS successRate FROM player
4300+
Player.select((cast(winsColumn, as: .real) / gamesColumn).forKey("successRate"))
4301+
```
4302+
4303+
See [CAST expressions](https://www.sqlite.org/lang_expr.html#castexpr) for more information about SQLite conversions.
4304+
42944305
- `IFNULL`
42954306

42964307
Use the Swift `??` operator:

0 commit comments

Comments
 (0)