Skip to content
What's new

Rent v0.8.13

Rent v0.8.13 makes automatic creation and edit timestamps use the database clock. Application instances can write consistent row timestamps without supplying their own wall-clock values.

Database-clock writes

@updatedAt now uses database time on creation and updates. Its existing explicit overrides, empty-update behavior and ignore exclusions remain available. The Rust-schema CreateTime, UpdateTime and Time mixins also use the database clock. @default(now()) retains its existing database-default behavior.

Generated timestamp fields gain a <field>_database_time(...) setter:

use rent::runtime::DatabaseTime;

let post = client
    .update_post_one(&post)
    .expires_at_database_time(DatabaseTime::statement().offset_seconds(300))
    .save_one()
    .await?;

This example assumes a writable expires_at DateTime? field. statement() selects statement time. wall_clock() selects evaluation time where the backend supports it. Ordinary non-key writes without value-observing policies, hooks or codecs compute the value inside SQL without a separate clock query, including eligible batched inserts and keyed updates.

Create authorization, before-write hooks, custom Rust policies and timestamp field codecs can require a preliminary evaluation. MySQL/MariaDB also evaluate clock-derived primary keys before inserting so the returned-row lookup uses the complete identity. Field-permission checks sample the expected timestamp in their existing row-lock query and continue checking stored values after triggers run. See automatic values for backend precision and transaction semantics.

Failed commit cleanup

If permission-cache change publication fails during commit, Rent waits for rollback before returning the error. This prevents an immediate follow-up query from racing cleanup and encountering a SQLite schema lock.

Upgrade

Pin the SDK, extension crates and CLI to v0.8.13, then regenerate the client and commit the consumer lockfile. Existing automatic-timestamp call sites need no new syntax. Remove application-side clock reads only where they existed solely to supply a timestamp that can now use a generated database-time setter.

Automatic timestamps change clock source. PostgreSQL automatic edit timestamps use statement time rather than transaction-start now(). Explicit timestamp setters still preserve supplied values. These changes do not install database triggers or replace optimistic-lock versions. Custom Rust default callbacks keep their authored behavior.