prorm API Reference
    Preparing search index...

    Function normalizeConstraintChecks

    • Compile any structured check predicates in a set of table constraints to SQL, leaving strings and every other field alone.

      A CHECK written on a model is the one piece of schema that used to require hand-written SQL: addConstraint has taken a where object for a while, but the constraint list handed to CREATE TABLE reached 22 dialects that each interpolate the predicate directly. Normalising here means the dialects keep receiving the string they always have, and the public API stops asking for SQL.

      constraints: [{ type: ConstraintType.Check, name: 'ck_age', check: { age: { gte: 0 } } }]
      // CONSTRAINT "ck_age" CHECK ("age" >= 0)

      Parameters

      • dialect: Dialect
      • constraints: readonly unknown[] | undefined

      Returns TableConstraint[] | undefined