- Ast.Query node + parser: `from <v> in <src> where* [group..into] [order by] [take] select <e>`, positional `from` trigger so it stays a usable identifier; select stays grammar-owned (no DbStub conflict) - typecheck: range var bound to the source table class; a table-class value is its row id at runtime but TYPES as the class, so `e.field` checks against the class fields; result is `multi <select-type>`; group/order/take/navigation diagnosed WO-E250 not-yet (honest edge) - emit: `from/where/select` lowers to a bytecode LOOP over DB_SCAN's materialized id list — DB_GET_FIELD per column read, where-guards skip the push, select projects, result is a fresh multi; no plan tree, no SQL text (disassembly-provable) - field access on a @table-class value routes to DB_GET_FIELD instead of GETF (clsrec.cr_is_table + is_table_class); non-table classes unchanged so log-watcher is unaffected - the ASan-caught bug kept in a comment: a table-class query element is a SCALAR id, not an OWNED pointer — tagging the result multi OWNED dropped an id as a pointer (SEGV in wo_drop_obj) - fixture run/db-query-scan (where-filter + select-whole + select-field); oop-e2e 74/0, woc-test 566/0, log-watcher 7/0 - SLICE scope: group-by aggregation, order/take, and ref/backlink navigation are the next chunk (employee report/staff/raise need them) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
22 lines
637 B
Text
22 lines
637 B
Text
-- iteration 9b: language-integrated query, from/where/select over a table
|
|
-- scan, lowered to a bytecode loop over engine cursors (no SQL text). A
|
|
-- table-class value is its row id; `e.name` reads the column via the engine.
|
|
@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 }
|
|
insert Emp { name: "chidi", salary: 50, dept: 2 }
|
|
for e in from x in Emp where x.salary >= 100 select x {
|
|
print(e.name)
|
|
}
|
|
print("--")
|
|
for n in from x in Emp select x.name {
|
|
print(n)
|
|
}
|
|
}
|