aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check.py
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-28 00:20:49 +0100
committereunhhu <[email protected]>2026-09-28 00:20:49 +0100
commit32b16a23a7ca7080b32a2948cd7518053125dac9 (patch)
tree2a5f2b6a9aa803dfa1e1af27b874ad0afeeedd9a /tests/check.py
parentd03092f8dc3efe2231c817031be0a744ac6e60e1 (diff)
downloadaup-32b16a23a7ca7080b32a2948cd7518053125dac9.tar.gz
aup-32b16a23a7ca7080b32a2948cd7518053125dac9.zip
Let a fold in a column read the column's row
A count, sum, max or min inside a table's column may now name the row the column is evaluated for: per branch, the sum of its accounts (sum(a.balance for a in accounts where a.bid == b.bid)), or per account, how many are richer. The column's row inside the fold compiles to OUTER_ROW, which Pure's verifier accepts only in a fold that runs in a column; the fold's own item stays ROW. This is a correlated subquery, the form SQL writes GROUP BY and self-joins with.
Diffstat (limited to 'tests/check.py')
-rw-r--r--tests/check.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/check.py b/tests/check.py
index 98d6e37..84fc9bd 100644
--- a/tests/check.py
+++ b/tests/check.py
@@ -196,8 +196,6 @@ DIAGNOSTICS = [
(LIST + 'view v = count(x in at)\n', '6:10', "'at' is not a list"),
('record T {\n t: text\n}\nstate xs: list of T\nview v = sum(x.t for x in xs)\n', '5:14',
'sum, max and min take numbers, not text'),
- (LIST + 'view w = each r in xs {\n n = count(x in xs where x.a == r.a)\n}\n', '7:34',
- "'r' is the column's row; a count, sum, max or min reads only its own item"),
(LIST + 'fn f(n) = count(x in xs where x.a == n)\nview v = f(1)\n', '6:38',
"'n' is a parameter outside this count, sum, max or min"),
(LIST + 'view v = sum(dt for x in xs)\n', '6:14', 'dt is not available in count, sum, max or min'),
@@ -234,6 +232,8 @@ DIAGNOSTICS = [
]
ACCEPTED = [
+ # A fold in a column reads the column's row too (a correlated subquery).
+ LIST + 'view w = each r in xs {\n n = count(x in xs where x.a == r.a)\n}\n',
SENDS + 'on buy {\n n = n + 1\n send ordered { to: { city: "Seoul" }, count: buy.count, item: buy.item }\n}\nview sent = n\n',
# fns named like folds stay calls, and max of two values stays max
'fn sum(a, b) = a + b\nfn count(x) = x\nview v = sum(1, count(2)) + max(3, 4) + min(\n 5,\n 6\n)\n',