diff --git a/Documentation/AssociationsBasics.md b/Documentation/AssociationsBasics.md index b517dea44..50e241674 100644 --- a/Documentation/AssociationsBasics.md +++ b/Documentation/AssociationsBasics.md @@ -2661,7 +2661,7 @@ Aggregates can be modified and combined with Swift operators: let request = Team.annotated(with: Team.players.min(Column("score")) ?? 0) ``` -- SQL functions `ABS` and `LENGTH` are available as the `abs` and `length` Swift functions: +- SQL functions `ABS`, `CAST`, and `LENGTH` are available as the `abs`, `cast`, and `length` Swift functions:
SQL diff --git a/README.md b/README.md index 6f28662b0..2acc668b6 100644 --- a/README.md +++ b/README.md @@ -4291,6 +4291,17 @@ GRDB comes with a Swift version of many SQLite [built-in functions](https://sqli For more information about the functions `dateTime` and `julianDay`, see [Date And Time Functions](https://www.sqlite.org/lang_datefunc.html). +- `CAST` + + Use the `cast` Swift function: + + ```swift + // SELECT (CAST(wins AS REAL) / games) AS successRate FROM player + Player.select((cast(winsColumn, as: .real) / gamesColumn).forKey("successRate")) + ``` + + See [CAST expressions](https://www.sqlite.org/lang_expr.html#castexpr) for more information about SQLite conversions. + - `IFNULL` Use the Swift `??` operator: