Mention that casts work for drift types

This commit is contained in:
Simon Binder 2023-01-06 17:32:05 +01:00
parent a6bede2aaa
commit d9072d7fac
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 11 additions and 1 deletions

View File

@ -142,6 +142,16 @@ by their name. For this, use `ENUMNAME(...)` instead of `ENUM(...)`.
For details on all supported types, and information on how to switch between the For details on all supported types, and information on how to switch between the
datetime modes, see [this section]({{ '../Getting started/advanced_dart_tables.md#supported-column-types' | pageUrl }}). datetime modes, see [this section]({{ '../Getting started/advanced_dart_tables.md#supported-column-types' | pageUrl }}).
The additional drift-specific types (`BOOLEAN`, `DATETIME`, `ENUM` and `ENUMNAME`) are also supported in `CAST`
expressions, which is helpful for views:
```sql
CREATE VIEW with_next_status AS
SELECT id, CAST(status + 1 AS ENUM(Status)) AS status
FROM tasks
WHERE status < 3;
```
### Drift-specific features ### Drift-specific features
To help support drift's Dart API, `CREATE TABLE` statements in drift files can To help support drift's Dart API, `CREATE TABLE` statements in drift files can