Skip to content

v0.8.2 β€” Prisma importer correctness + JSON defaults

Choose a tag to compare

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

Fixed

  • prax-import (Prisma) β€” @default value round-trip. The Prisma
    importer now emits .prax output that reparses. Three underlying bugs
    were fixed together:
    • String literal defaults (@default("standard")) no longer round-trip
      as doubled quotes (@default(""standard"")). The source quote
      characters are stripped before stashing in AttributeValue::String.
    • Bare-identifier defaults on enum fields (@default(PENDING)) now map
      to AttributeValue::Ident instead of AttributeValue::String. The
      emitter was writing them as quoted string literals, which the parser
      rejected on an enum-typed field.
    • dbgenerated("uuid_to_text(id)") arguments are unquoted the same way
      so they don't double-quote either.
  • prax-import (Prisma) β€” pgvector columns. Prisma models pgvector
    columns via Unsupported("vector(N)"). The importer now recognizes
    the four pgvector shapes (vector(N), halfvec(N), sparsevec(N),
    bit(N)) inside the Unsupported(…) payload and translates them to
    the matching ScalarType::Vector(…) / HalfVector(…) / SparseVector(…)
    / Bit(…) variants. The emitter prints the dimension via the
    @dim(N) attribute that the schema parser already accepts.
  • prax validate β€” diagnostic rendering. The CLI now renders schema
    errors via miette::Report with the source attached, so the specific
    prax::schema::invalid_field, unknown_type, etc. diagnostic is
    visible. Previously every parse or validation failure surfaced as the
    same bare "syntax error in schema" string, which hid the actionable
    detail.
  • prax-schema validator β€” Json default values. The validator now
    accepts String, Array, Boolean, Int, and Float payloads as
    the @default of a Json-typed field. Prisma encodes JSON defaults
    as quoted text literals (@default("[]"), @default("{}")), which
    are valid because Postgres parses the text into jsonb at insert
    time β€” the old validator only accepted String defaults on
    String-typed fields, rejecting every JSON default outright.

Motivation

Discovered importing the Lexmata schema.prisma (71 models, 33 enums,
1,149 fields, 226 relations) as part of LD-15 / LX-33 β€” the
admin-backend is adopting Prax as its in-tree ORM and needed a
committable schema.prax regenerated from the authoritative Prisma
schema. The import was failing and the generic "syntax error" message
was masking four distinct bugs; each is now a named regression test.