- `order by <field> [desc]` on whole-row queries: a selection sort over the result multi, re-reading the key per element via the range var (DB_GET_FIELD); O(n^2), KISS, no cost planner — the result sets are small by design - Text order keys use a new WO_B_STR_LT builtin (content compare, reusing the WO_B_SORT elem_cmp); scalar keys use the LT opcode. The bug this fixes: op_lt on two Text pointers compares ADDRESSES - `take N`: clamp to count, slice [0,N). `take` is the KwTake keyword, not an Ident — matched as the token - two bugs found + fixed while testing: multi-line query clauses (skip the separating newlines) and the key-kind read (must bind the range var BEFORE ty_of_expr of the order key, or a Text key silently uses op_lt); Index typechecks to the container's element type (`ds[0]`) - fixture run/db-query-order; oop-e2e 75/0, woc-test 566/0, 15 runtime suites, log-watcher 7/0 - employee `seed`/`list`/`staff` modes now compile and run; report (group-by+projection), raise (update), drop (delete) remain Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
16 lines
533 B
Text
16 lines
533 B
Text
-- iteration 9b: order by (whole-row selection sort, Text-aware) + take.
|
|
@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: 300, dept: 1 }
|
|
insert Emp { name: "dora", salary: 200, dept: 1 }
|
|
print("salary desc:")
|
|
for e in from x in Emp order by x.salary desc select x { print(e.name) }
|
|
print("name asc take 2:")
|
|
for e in from x in Emp order by x.name take 2 select x { print(e.name) }
|
|
}
|