github tokio-rs/toasty toasty-v0.7.0
Toasty v0.7.0

4 hours ago

Highlights

Relations are now plain fields, with eager loading by default. The HasMany, HasOne, and BelongsTo wrapper types are gone. A relation field is just its target type, and whether you wrap it in Deferred controls when it loads: a bare field loads eagerly with its parent, a Deferred<...> field loads on demand (via .include() or an accessor).

#[has_many]
posts: Vec<Post>, // eager — loaded with the User

#[has_one]
profile: toasty::Deferred<Option<Profile>>,  // on demand

Multi-step via relations. Declare relations that traverse an intermediate relation, and load them with .include():

#[has_many(via = posts.comments)]
comments: toasty::Deferred<Vec<Comment>>,

update! macro. A new macro for updates, mirroring create!. Set multiple fields in one call, with field shorthand, embedded-struct patches, and has-many inserts:

toasty::update!(user {
    name: "Carlos",
    email: "carlos@example.com",
})
.exec(&mut db)
.await?;

Arithmetic updates. Numeric fields get increment, decrement, add, and subtract, compiled to in-place column updates and usable as method shorthand inside update!:

toasty::update!(comment { views.increment() }).exec(&mut db).await?;

Turso driver. libSQL now joins SQLite, PostgreSQL, MySQL, and DynamoDB. On SQLite and Turso, TransactionMode lets you pick the lock-acquisition strategy for concurrent writers.

Raw SQL. An escape hatch for queries the builder doesn't cover, with typed results.

New field wrappers. Deferred<T> (replaces #[deferred]) and toasty::Json<T> (replaces #[serialize(json)]) are ordinary types — they compose with Option, embeds, and derives.


Changelog

toasty

Added

  • Derive Clone and add Deserialize for Deferred<T> (#994)
  • [breaking] Increment, decrement, add, and subtract update operators (#979)
  • update! macro for concise field updates (#980)
  • Reject create() on multi-step relation scopes at compile time (#978)
  • Raw SQL execution API (#965)
  • Remove the #[deferred] attribute in favor of Deferred<T> (#961)
  • Eager relation fields (#958)
  • .include() of multi-step via relations (#946)
  • Expose migration core from toasty (#944)
  • Turso driver with TransactionMode-aware concurrent writes (#938)
  • Dispatch has-many stmt::apply batches per entry (#932)
  • TransactionMode for SQLite lock-acquisition control (#931)
  • Allow #[version] on tuple-newtype embeds of u64 (#930)
  • Serialize SELECT DISTINCT (#934)
  • [breaking] Replace #[serialize(json)] with the toasty::Json<T> wrapper (#926)
  • Expose the primary-key type via Model::PrimaryKey (#921)
  • Fold simple Batch assignments in update lowering (#917)
  • Multi-step (via) has_many and has_one relations (#890)
  • Non-panicking try_get on relation types (#918)

Fixed

  • Deserialize a present Deferred<T> value as loaded (#999)
  • Lift relation-path LIKE into a foreign-key subquery (#992)
  • Lift relation-path IN-subquery through BelongsTo chains (#990)
  • Make starts_with case-sensitive on SQLite and MySQL (#983)
  • Handle ExprOr in eval verify_expr (#959)
  • [breaking] Scope .ilike() to PostgreSQL and document operator pass-through (#937)

Other

  • [breaking] Merge one-relation field traits (#971)
  • Simplify Field bounds now that Load<Output = Self> is required (#976)
  • Move UpdateTarget::Query rewrite into lower (#975)
  • [breaking] Delete the Relation trait, tighten relation field shapes (#967)
  • Split via relations into a field variant (#966)
  • [breaking] Merge has-relation field variants (#964)
  • [breaking] Require Deferred relation fields (#954)
  • Gate the SQLite connect doctest (#953)
  • Split relation field traits from targets (#950)
  • Unify lazy-slot relation encoding (#949)
  • [breaking] Move schema diff types to schema::diff (#929)
  • Consolidate migration types and reorganize the db::diff API (#928)

toasty-core

Added

  • INNER join variant (#922)

Fixed

  • Cap SQLite auto-increment integer storage at 4 bytes (#969)

toasty-macros

Added

  • [breaking] Remove singular has-many create-builder methods (#977)

Fixed

  • Respect the pair attribute in the #[has_one] macro (#927)

toasty-sql

Other

  • Rename types in toasty_core::schema::diff (#942)

toasty-driver-postgresql

Added

  • Adopt tokio-postgres-rustls 0.14 (#952)

Fixed

  • Accept libpq query-param connection options (#985)

toasty-driver-dynamodb

Fixed

  • Omit empty ExpressionAttributeValues on IS NULL / IS NOT NULL scans (#940)

Other crates

toasty-driver-mysql, toasty-driver-sqlite, toasty-driver-turso, toasty-cli, and the integration-suite crates received the shared changes listed above (raw SQL API, Turso driver, required Deferred relation fields, schema-diff move) with no crate-specific entries.

Don't miss a new toasty release

NewReleases is sending notifications on new releases.