Skip to content

v0.9.0 — prax generate now emits a runtime-ready client

Choose a tag to compare

@quinnjr quinnjr released this 30 Apr 18:52
· 46 commits to main since this release
3071205

Added

  • prax generate now emits a runtime-ready client. Generated
    model modules carry the trait impls the runtime needs to actually
    run queries, matching the surface produced by #[derive(Model)]:
    • impl prax_query::row::FromRow decodes scalar columns via
      FromColumn and default-initializes relation fields, so
      find_many and friends round-trip rows back into the generated
      structs at runtime.
    • impl prax_query::traits::ModelWithPk exposes pk_value() and
      get_column_value() for nested writes, upsert, and composite
      primary keys.
    • The per-model operations struct is named Client<E> (was
      {Name}Operations<E>), so prax_orm::client!(User, Post, ...)
      can resolve <snake_name>::Client<E> by path the same way it
      does for the derive path. The full CRUD surface — find_many,
      find_unique, find_first, create, create_many, update,
      update_many, upsert, delete, delete_many, count — is
      emitted on Client<E>.
    • Non-list relation fields are emitted as Option<T> (or
      Option<Box<T>> when boxing is needed to break a cycle)
      regardless of the schema modifier, so the FromRow default-init
      has a None to write into. The relation executor populates
      Some(T) on the .include path.

Fixed

  • prax-migrate — CREATE TABLE emission respects FK dependencies.
    Before, SchemaDiffer populated create_models by iterating a
    HashMap, leaving the resulting CREATE TABLE order
    non-deterministic. A schema where tracks and playlists
    reference sync_sources could emit sync_sources last; SQLite
    tolerated it because FK targets are resolved at row-write time,
    but strict engines (Postgres, MySQL with FK enforcement, MSSQL)
    and any deferred-constraint bootstrap would fail to apply the
    migration. SchemaDiff::ordered_create_models now does Kahn's
    algorithm topo sort over the FK graph: referenced tables emit
    before their dependents, self-references and FKs that point at
    out-of-batch tables don't constrain ordering, and cycles fall
    back to original order. All five SQL generators (Postgres,
    MySQL, SQLite, MSSQL, DuckDB) route through it and emit drops
    in the reverse direction so rollbacks drop dependents before
    parents.

Changed

  • Workspace clippy gate is back online. The husky pre-commit
    hook had silently been bypassed in environments that override
    core.hookspath with no project-local pre-commit; develop had
    accumulated 200+ clippy errors under -D warnings. Cleared every
    diagnostic so
    cargo clippy --workspace --all-targets --all-features -- -D warnings
    passes again. API-shape lints (result_large_err,
    new_ret_no_self, should_implement_trait, pedantic noise in
    prax-scylladb) are suppressed at crate level with rationale;
    bug-shaped lints (manual_checked_ops, manual_strip,
    manual_clamp, manual_sort_by_key, &PathBuf&Path,
    mixed_attributes_style, unnecessary_unwrap) are fixed in
    place.
  • prax-sqlite — vector tests skip cleanly when the loader is
    unconfigured.
    The two unit tests in vector/register.rs and
    the three integration tests in tests/vector_integration.rs no
    longer fail under cargo test -- --include-ignored (used by CI)
    in environments that haven't provisioned the sqlite-vector-rs
    cdylib. They detect the missing library at runtime via
    SQLITE_VECTOR_RS_LIB and bail out with a "skipping" message
    instead of panicking on the loader error.