pub const GENERATED: ColumnMarker;Expand description
Marks a column as a GENERATED AS (expression) column.
§Syntax
generated(stored, "expression")- Computed on write, stored on diskgenerated(virtual, "expression")- Computed on read, not stored (PostgreSQL 17+)
§Example
ⓘ
#[column(generated(stored, "price * quantity"))]
total: i32,
#[column(generated(virtual, "first_name || ' ' || last_name"))]
full_name: String,§Technical Details
Generated columns cannot be written to directly. STORED columns are computed and stored on write. VIRTUAL columns are computed on read (PostgreSQL 17+).
See: https://www.postgresql.org/docs/current/ddl-generated-columns.html