Skip to content
What's new

Rent v0.8.8

More efficient permission checks, flexible edit versions, projected update results, and safer migration planning.

Reuse independent permission checks

Adding a read-only view no longer disables reusable permission and foreign-key checks for unrelated models. Checks that depend on views or database policies remain conservative. Bulk updates also reuse repeated reference checks during final verification, while separate writes still recheck authorization.

Keep bookkeeping out of edit conflicts

Versioned models can declare @@rent.version(ignore: [view_count]) to keep background counters and other selected fields from advancing the edit version. Writes that also change ordinary fields still advance it, and explicit version preconditions still apply. See optimistic locking.

Authorize deletion independently

Use @@rent.delete(requireRead: false) when a caller may delete a record without reading it. This opt-in applies to single-row and filtered deletes. Tenant scope, delete rules, mutation policies, hooks, and version preconditions remain enforced. The default still requires read access. Review restrictions previously supplied by read policies before opting in. See delete permissions.

Return updated fields and compose projections

Filtered updates support .save_returning((Post::id, Post::title)) and named stored-field projections. Results include stored trigger changes, even when a row stops matching the original filter. Selection, mutation, verification, and result decoding share a transaction across supported databases.

These are mutation results: an authorized update can return requested fields even when the resulting row is no longer readable. Subsequent reads enforce read permission. This method may execute multiple statements. Computed selections and relationship mutations are not supported by this terminal method. See update results.

Projection queries also accept filters, ordering, limits, and offsets after select(...) or a single-field selection. Use exist() for existence checks.

Make fixed enum predicates explicit

For PostgreSQL partial indexes, use a typed predicate such as .filter(Post::status.eq_fixed(PostStatus::Queued)). PostgreSQL receives the enum's escaped stored label as a constant, allowing generic plans to consider a matching partial index. Index selection still belongs to the database planner. Ordinary enum filters remain parameterized. See queries.

Safer schema validation and migrations

  • Primary-key replacements release old key columns before relaxing their nullability. Newly required key columns are prepared before the replacement.
  • Invalid index and key sort directions now produce diagnostics instead of silently becoming ascending.
  • Recognizable enum comparisons in checks and partial-index predicates are validated against stored labels. This is bounded validation, not a complete analysis of arbitrary SQL.
  • PostgreSQL UPDATE OF trigger column lists survive inspection and planning.
  • migration.protect entries preserve named indexes and triggers when using --drop-objects. Conflicting or unsafe dependent changes require explicit review.
  • PostgreSQL index storage settings can be declared in the schema. Ordinary SQL and PL/pgSQL functions can be managed explicitly in rent.toml, including overload identities, SQL body files, and declared dependencies. Advanced function forms remain managed through SQL migrations.
  • SQLite table rebuilds retain rows when no writable source column survives, using valid destination defaults or nulls. An impossible conversion fails without discarding the original rows.

See migration planning, including the complete PostgreSQL function example.

Permission-aware SQL inspection now returns QueryInspectionRequiresSetup when the query requires session setup that standalone SQL cannot represent. Normal query execution is unchanged.

Upgrade

Use v0.8.8 for every Rent crate and the CLI, regenerate all configured clients, and commit the application lockfile. Run validation to catch invalid sort directions or stored enum labels. Review newly generated migrations before applying them. Do not rewrite migrations that have already been applied.

Existing models retain their versioning and delete-visibility defaults. Enable the new options only where their contracts fit the application. Detailed SDK instrumentation remains disabled unless explicitly enabled.