- FK restrict: deleting a row a non-nullable `ref` still points at traps WO_T_FK (11), catchable. The compiler now records a `ref` field's target class in the class-table field_class metadata; the engine (wo_row_has_referrers) scans referencing scalar columns before a delete. Correctness-first full scan; the backlink-index optimization is recorded for later - docs/examples/employee now COMPILES AND RUNS all six modes against a WAL-durable database: seed (+@unique trap across restart), report (per-dept aggregates + payroll), staff (unique probe + backlink + ref nav), raise (update-through-row), drop (FK restrict), and persistence via replay - group-by SYNTAX parked to a future iteration (user decision): the report mode is hand-rolled from the shipped primitives meanwhile (same numbers). "table relations and FK" is complete - scripts/employee-accept.sh (8 checks) + a `just employee` module; manifest parser tolerates iteration 9c's [share]/[[share.clients]] sections so `woc .` builds the sample on this branch - fixtures trap/db-fk-restrict (code 11) + run/db-fk-restrict-catch; oop-e2e 79/0, woc-test 566/0, 15 runtime suites, log-watcher 7/0, employee-accept 8/0 - 9b story + status board updated Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
23 lines
706 B
Text
23 lines
706 B
Text
-- the restrict trap is catchable; a free (unreferenced) row deletes.
|
|
@table(name: "dept", index: [name])
|
|
class Dept {
|
|
name: Text
|
|
staff: backlink Emp.dept
|
|
}
|
|
@table(name: "emp", index: [dept])
|
|
class Emp {
|
|
name: Text
|
|
dept: ref Dept
|
|
}
|
|
fn main() {
|
|
let eng = insert Dept { name: "eng" }
|
|
let ops = insert Dept { name: "ops" }
|
|
insert Emp { name: "asha", dept: eng }
|
|
let de = from x in Dept where x.name == "eng" take 1 select x
|
|
let r1 = try delete de[0] catch (e) nil
|
|
if r1 == nil { print("eng restricted") }
|
|
let dop = from x in Dept where x.name == "ops" take 1 select x
|
|
let r2 = try delete dop[0] catch (e) nil
|
|
if r2 == nil { print("ops restricted (WRONG)") }
|
|
print("ops deleted")
|
|
}
|