mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Documentation for cast function
This commit is contained in:
1 parent
32642d566b
commit
2ad1f37d2b
2 files changed
+12
-1
No files matched your search
@@ -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:
|
||||
|
||||
<details>
|
||||
<summary>SQL</summary>
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user