Highlights
#[version] works on SQL. Optimistic concurrency was DynamoDB-only. It now runs on SQLite, PostgreSQL, MySQL, and Turso: creating a record initializes the field to 1, every update and delete increments it, and writing through a stale snapshot fails the condition check instead of clobbering the newer row.
#[version]
version: u64,#[belongs_to] infers its keys. The key and references arguments are derived from the field name and the target's primary key, so the common case is a bare attribute:
#[belongs_to]
user: toasty::Deferred<User>,Optional embeds and shared enum columns. An embedded struct can be Option, and enum variants can store a common field in one column by naming it:
metadata: Option<Metadata>,
enum Creature {
Human { #[column("name")] name: String, profession: String },
Animal { #[column("name")] name: String, species: String },
}Both variants write creature_name; profession and species keep their own columns.
Composite unique indices. A model attribute declares uniqueness over several fields at once. SQL backends lower it to a unique index; DynamoDB rejects it with unsupported_feature.
#[unique(org_id, slug)]
struct Account { /* ... */ }Query DSL additions. between(lo, hi) (inclusive, and usable as a DynamoDB sort-key condition), like_with_escape(pattern, escape_char) for patterns containing literal % or _, and indexes on unit enum fields.
Tracing. Each statement the driver executes emits one toasty::query event carrying duration_ms, rows, error, and the OpenTelemetry db.* fields, under the caller's span. Events past the slow-statement threshold are logged at WARN.
Changelog
toasty
Added
- Emit one
toasty::queryevent per statement and propagate caller spans (#1071) - Support
#[version]optimistic concurrency on SQL drivers (#1065) - Infer
keyandreferencesin#[belongs_to](#1063) - Share columns across enum variants via
#[column("name")](#1064) - Escape support for
LIKEexpressions (#1039) set_*replace-variants on the query builder (#1037)- Serde serialization and deserialization for
toasty::Json<T>(#1035) - Index unit enum fields (#1027)
betweenoperator in the query DSL (#1029)- Composite unique indices (#1018)
Option<EmbeddedType>model fields (#1021)- Scalar terminal fields in
has_manyrelations (#1012)
Fixed
- Avoid a panic when updating a mixed enum to a unit variant (#1069)
- Fix enum decoding for OR'd variant filters (#1067)
- Make multi-key delete and update consistent (#1053)
- Truncate auto-generated index names that exceed the backend limit (#1023)
- Increment the
#[version]field on query-based updates (#1022)
Other
- [breaking] Derive default table names at compile time (#1070)
- [breaking] Make
UpdateByKeyreturning columns explicit (#1024) - [breaking] Rename the
RelationManyField/RelationOneFieldassociated type toTarget(#1015) - [breaking] Align
stmt::Querywith the per-modelQuery(#1011) - [breaking] Unify per-model query structs into
Query<T>(#995) - [breaking] Remove the
Registertrait (#1006) - Remove compile-time field validation from the
create!macro (#997)
toasty-core
Fixed
- Encode bool values to match the DynamoDB key attribute type (#945)
Other
- [breaking]
Model::table_nameis now aStringrather than anOption<String>(#1070)
toasty-sql
Added
- Serialize
#[version]condition checks for optimistic concurrency (#1065) - Serialize
LIKE ... ESCAPE(#1039) - Serialize
BETWEEN(#1029)
toasty-driver-sqlite
Fixed
- Propagate errors from
exec_sqlinstead of panicking (#1007)
toasty-driver-dynamodb
Fixed
- Make multi-key delete and update consistent (#1053)
- Encode bool values as
N("1"/"0")to match the key attribute type (#945)
toasty-cli
Fixed
- Include the path in Toasty config load errors (#1036)
Other crates
toasty-macros, toasty-driver-postgresql, toasty-driver-mysql, toasty-driver-turso, and the integration-suite crates received the shared changes listed above (query events, #[version] on SQL, #[belongs_to] inference, unified Query<T>, compile-time table names) with no crate-specific entries.