IF Commons GitHub

sql/physical/enforcement

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0043-sql-invariants FR-006

What a dialect can enforce in the database (commons data 0043-sql-invariants FR-006). Engines differ in what they let a database refuse by itself: PostgreSQL has triggers, stored routines, row security, grants, event triggers and advisory locks; SQLite has checks, keys and triggers and no roles; DuckDB has checks, keys and uniqueness and no triggers. A guarantee that an engine cannot enforce in the database is not a defect of the engine or of the library: it is enforced by the application's runtime, and the library says which. A guarantee that an engine can enforce in the database and is enforced only by the application is a defect of the library.

Source: commons/data/sql/physical/enforcement.ts

2 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Enforcementinterfaceno test imports it
interface Enforcement

What a dialect can and cannot make the database do.

MemberTypeWhat it is
tierTier
canreadonly Mechanism[]
cannotreadonly { readonly mechanism: Mechanism; readonly because: string; }[]
enforcementOffunction
function enforcementOf(dialect: Dialect): Enforcement

What a dialect can enforce in the database.

ParameterWhat it is
dialectthe dialect

Returns: its tier, what it can do and what it cannot, and why

Imported by 2 tests of the run (2 passed, 0 failed): the library's results

Mechanismtypeno test imports it
type Mechanism = "check" | "foreign-key" | "unique" | "trigger" | "routine" | "row-security" | "grant" | "event-trigger" | "transactional-ddl" | "advisory-lock";

A way a database refuses what is wrong.

Needtypeno test imports it
type Need = "append-only" | "status-moves" | "column-cap" | "hash-chain" | "row-isolation" | "least-privilege" | "no-weakening" | "single-runner";

A guarantee a model may ask of the database.

Tiertypeno test imports it
type Tier = "full" | "standard" | "basic";

How much a dialect lets the database do: everything below, plus roles and routines (full); checks, keys and triggers (standard); checks and keys alone (basic).

wherefunction
function where(dialect: Dialect, need: Need): { readonly by: "application" | "database"; readonly via: string; }

Where a guarantee can be enforced for a dialect.

ParameterWhat it is
dialectthe dialect
needthe guarantee

Returns: database where the database itself can refuse what breaks it, application where only the application's runtime can, and how

Imported by 2 tests of the run (2 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.