writeonce/tests/corpus/run/db-update-delete/fixture.wo
shoney.arickathil fa4b282934 feat(compiler): update-through-row + delete statement (9b cont.)
- `e.field = v` where e is a table row lowers to DB_UPDATE_FIELD
  (class, id, field, value) — the row's indexes maintained at the choke
  point; heap-object field assignment still emits SETF unchanged
- `delete <row>` expression: DB_DELETE(class, id), yields the id so it
  composes in `try delete x catch (e) nil` (restrict/trap surfaces
  catchably); Delete AST node threaded through type/owner/dump/emit
- disassembly-caught bug fixed: in tail position dst == the builtin
  window's first reg, so moving the id into dst clobbered the class id
  — reserve dst past the window (the emit_ctor guard)
- run/db-update-delete fixture; oop-e2e up, woc-test 566/0,
  log-watcher 7/0
- employee seed/list/staff/raise/drop now compile+run; only `report`
  (group-by aggregation + projection record) remains

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 05:24:58 +02:00

19 lines
686 B
Text

-- iteration 9b: update-through-row (e.f = v -> DB_UPDATE_FIELD) and the
-- delete statement (delete <row> -> DB_DELETE), both via the choke point.
@table(name: "emp", index: [dept])
class Emp {
name: Text
salary: Int
dept: Int
}
fn main() {
insert Emp { name: "asha", salary: 100, dept: 1 }
insert Emp { name: "bram", salary: 200, dept: 1 }
for e in from x in Emp select x { e.salary = e.salary + 50 }
print("after raise:")
for e in from x in Emp order by x.name select x { print("${e.name} ${e.salary}") }
let gone = from x in Emp where x.name == "asha" take 1 select x
delete gone[0]
print("after delete:")
for e in from x in Emp select x { print(e.name) }
}