Learn by example
15. Views, generated columns, and triggers
Views can be read through generated models while generated columns and triggers stay owned by the database. The chapter executes all three concepts against SQLite:
let viewed = client.user_name_view().only().await?;It then inserts into a table with a stored generated length and an insert trigger, reading back both computed values. Finally it renders a PostgreSQL row-level-security policy and verifies both ENABLE ROW LEVEL SECURITY and CREATE POLICY are present. PostgreSQL domains use the same backend-specific schema path and are exercised by the live SQL matrix.
The chapter's generated view is declared in
crates/rent/examples/tutorial_14_database_objects/schema.rsl.
Run cargo run -p rent --example tutorial_14_database_objects. The same database-object workflow runs under nextest.