diesel::update. Portable Diesel on the DuckDB backend.
Updating columns
diesel::update(target).set(...) where target is a filtered table. Set one column, or a tuple of
columns:
.execute returns the number of rows changed.
Expressions in SET
The right-hand side can reference columns and DuckDB scalar functions, not just literals:Updating from a struct
A#[derive(AsChangeset)] struct turns into the SET clause. Option fields that are None are
omitted from the clause — a convenient partial-update pattern:
AsChangeset.
To treat a
None as “set this column to NULL” rather than “leave it alone”, add
#[diesel(treat_none_as_null = true)] to the AsChangeset struct — this is Diesel’s own attribute.Returning updated values
Chain.returning(...) with get_result/get_results to read columns back after the update:
See also
Delete
Remove rows.
Upsert
Insert-or-update in one statement.
RETURNING
Read values back from an update.
DSL overview
Functions usable in a SET expression.