Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Known Limitations (v0.1.0)

Verified against source. Grouped by how likely you are to hit them.

You’ll hit these on day one

Comparison operators only exist for String and Int

eq, not_eq, gt, gte, lt, lte are implemented only for Field<E, String> and Field<E, i32>.

Not available on: Boolean, Float, DateTime, Decimal, Json, and every nullable field (Option<T>).

rust Post::published.eq(true) // ✗ won't compile User::created_at.gt(cutoff) // ✗ User::bio.eq("x") // ✗ nullable User::bio.is_null() // ✓ null checks work on any type

Workaround: raw SQL for that query. See Query Builder.

Update structs have no Default

..Default::default() won’t compile. List every field, None to skip. Over JSON this is a non-issue — serde fills absent fields.

Literal defaults are still required in Create

@default(0) / @default(false) do not make a field optional. Only autoincrement() and now() are excluded.

Loaded many-to-one relations don’t serialize

Back-references carry #[serde(skip)] to prevent recursion. A loaded Post.user is invisible in raw model JSON. Use DTOs.

sqlx must be 0.8

Zyvor 0.1 depends on sqlx 0.8. Using 0.9 puts two sqlx_core versions in your graph and produces FromRow / Acquire trait-bound errors.

Query builder

LimitationDetail
Single ORDER BY columnsecond order_by() replaces the first
HAVING can’t compare aggregates.count() returns SelectItem, which has no .gt()
count() ignores GROUP BY / HAVING / LIMIT / OFFSETcounts joins + WHERE only
count() / fetch_all() are pool-onlytake &PgPool, not impl Acquire — no transactions
Unqualified GROUP BY / ORDER BYcan be ambiguous when joining tables with shared column names
No first() / one() / like()use all() + .into_iter().next(), or raw SQL
No CTE, UNION, FOR UPDATE—

Relations

LimitationDetail
with_nested needs a collection relationrequires RelationLoader (Vec). .with_nested(Post::user, ..) won’t compile
Unloaded vs empty is ambiguous[] / None means both. Only trust it after .with()
Composite foreign keysparsed, but codegen handles single-column only
Pivot tablesmust be declared as an explicit model

Schema

LimitationDetail
Primary key must be Intupdate/delete take id: i32 concretely
Composite @@idunsupported — surrogate id + @@unique([...])
Scalar arrays (String[])parsed, rejected by CRUD generation
@updatedAtparsed, no behaviour generated
@default(cuid())parsed, no SQL default
Block commentsnot supported
Validator gapscardinality/array-shape consistency, default-value type compatibility, full @@index/@@unique field validation
Error locationsno line/column in messages yet

Types

  • DateTime → TIMESTAMP, not TIMESTAMPTZ. No timezone stored.
  • Int → i32 (not i64).

Errors

A typed Error enum exists and auto-classifies PostgreSQL 23505 / 23503 / RowNotFound. Matching on variants works.

Rough edges in 0.1:

IssueDetail
Memory leakFrom<sqlx::Error> uses Box::leak for &'static str fields. Every classified constraint violation leaks two allocations permanently
Placeholder fieldsNotFound.entity = "unknown", NotFound.id = -1, ForeignKeyViolation.referenced_entity = "unknown"
Fragile parsingentity/field derived from constraint-name splitting; breaks on multi-word tables (user_profiles_user_id_key → field id)
UniqueViolation.valueholds the full PG message, not the duplicate value
Two error typesCRUD → zyvor::Error; queries → sqlx::Error. Bridge with .map_err(zyvor::Error::from)
Two migration error systemsruntime MigrationError enum vs CLI’s formatted-string errors
Generation misuseruntime input validation reported as a codegen error variant

Guidance: match on variants for status codes; write your own user-facing messages rather than trusting entity / field.

Migrations

MissingWorkaround
ALTER COLUMN TYPEhand-write a forward migration
rename detection⚠️ a rename becomes DROP + ADD — data loss. Review every diff
index / constraint diffshand-write
rollback, migrate status, migrate resetforward migration
auto pivot tablesdeclare the pivot model

Database support

PostgreSQL only. SQLite and MySQL are not implemented.

Planned

0.1.1 — additive, non-breaking

  1. Default derive on Update structs
  2. count / fetch_all generic over Acquire (transaction support)
  3. Multi-column order_by
  4. migrate status
  5. Populate NotFound / referenced_entity properly; use db_err.table() / .column() instead of constraint-name parsing

0.2.0 — breaking

  1. Comparison operators for bool, f64, DateTime, Decimal, Option<T>
  2. Error enum fields &'static str → String (removes the Box::leak leak)
  3. Unified error type across queries and CRUD

Primary key must be an Int column literally named id

update and delete emit WHERE id = $1. Both the type (i32) and the column name (id) are hardcoded. @mapping your PK to another name breaks these two methods; update_many / delete_many still work.

Identifiers are unquoted in the executor

Migrations quote identifiers; the executor does not. Use lowercase snake_case table and column names. @@map("User") or any name needing quoting will fail at runtime.

Empty update is an error

All-None update → Err(Error::Generation(..)), not a no-op. Guard PATCH endpoints.

Models with only auto-generated fields

If every column is @default(autoincrement()) or @default(now()), the generated Create struct has no fields and the INSERT has an empty column list. Keep at least one user-supplied column per model.