@omgbase/core 0.27.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/oqx-js/context.js +7 -10
- package/dist/src/oqx-js/run.js +4 -3
- package/package.json +1 -1
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// store's raw column objects, tagged with their target; `get` routes field /
|
|
6
6
|
// intrinsic / relation resolution per target, lazily querying the store for
|
|
7
7
|
// relations. Domain functions (text/semantic/under_*/…) are row-scoped, so they
|
|
8
|
-
// arrive via `callMethod` on
|
|
9
|
-
//
|
|
8
|
+
// arrive via `callMethod` on the row as receiver — run.ts's AST rewrite turns
|
|
9
|
+
// them into `$it.fn(…)` — rather than as free functions (which see no row).
|
|
10
10
|
//
|
|
11
11
|
// This is the correctness tier: N+1 queries, materialized collections — fine for
|
|
12
12
|
// the corpus and the differential baseline. The tier-3 SQLite planner (planner.ts)
|
|
@@ -612,13 +612,10 @@ export function makeStoreContext(store, repoId, opts = {}) {
|
|
|
612
612
|
return row[key];
|
|
613
613
|
}
|
|
614
614
|
const r = row;
|
|
615
|
-
// `$
|
|
616
|
-
//
|
|
617
|
-
//
|
|
618
|
-
//
|
|
619
|
-
// an omgbase attribute.
|
|
620
|
-
if (key === "$self")
|
|
621
|
-
return r;
|
|
615
|
+
// A `$` name is OQX's (`$it`, `$key`, … — resolved by the engine before
|
|
616
|
+
// the row) or unknown — never an omgbase attribute. Row-scoped domain
|
|
617
|
+
// functions (text/semantic/under_*/…) never arrive here: run.ts rewrites
|
|
618
|
+
// them to `$it.fn(…)`, so they reach callMethod with the row as receiver.
|
|
622
619
|
// engine attributes win on collision (the name rule above).
|
|
623
620
|
if (ATTRIBUTES[t].has(key))
|
|
624
621
|
return attribute(r, t, key);
|
|
@@ -670,7 +667,7 @@ export function makeStoreContext(store, repoId, opts = {}) {
|
|
|
670
667
|
return jattr(r, key);
|
|
671
668
|
return undefined;
|
|
672
669
|
};
|
|
673
|
-
// ---- domain functions (row-scoped, via callMethod on
|
|
670
|
+
// ---- domain functions (row-scoped, via callMethod on `$it`) ---------------
|
|
674
671
|
const method = (name, recv, args) => {
|
|
675
672
|
const r = recv;
|
|
676
673
|
const t = r?.[TARGET];
|
package/dist/src/oqx-js/run.js
CHANGED
|
@@ -17,7 +17,8 @@ import { referencePath } from "../core/paths.js";
|
|
|
17
17
|
import { canonicalJson } from "../mutate/canonical.js";
|
|
18
18
|
// Row-scoped domain functions: authored as free calls (`text("x")`) that
|
|
19
19
|
// implicitly reference the current row. `@omgbase/oqx` free functions receive no
|
|
20
|
-
// row, so we rewrite them to `$
|
|
20
|
+
// row, so we rewrite them to `$it.fn(…)` (a method whose receiver is the row —
|
|
21
|
+
// `$it` is the language's own name for the scope's row, spec/oqx SEMANTICS §2)
|
|
21
22
|
// — one `transform` over the AST (spec/oqx/AST.md §5), every block included.
|
|
22
23
|
// `refs(x)` is NOT here: it reads no row (its argument is the value), so it stays
|
|
23
24
|
// a free function served by the context's `callFunction`. The planner treats
|
|
@@ -118,7 +119,7 @@ export function foldDates(e) {
|
|
|
118
119
|
return build.lit(dateMethod(e.name, e.recv.value, args).value);
|
|
119
120
|
}
|
|
120
121
|
function rewriteQuery(q) {
|
|
121
|
-
return transform(q, (e) => (e.kind === "call" && e.recv === null && ROW_FNS.has(e.name) ? { ...e, recv: build.ident("$
|
|
122
|
+
return transform(q, (e) => (e.kind === "call" && e.recv === null && ROW_FNS.has(e.name) ? { ...e, recv: build.ident("$it") } : foldDates(rootPathLiterals(e))));
|
|
122
123
|
}
|
|
123
124
|
// A top-level `limit`/`offset` on the collect path is applied by the runner (see
|
|
124
125
|
// oqxRunInner), so it must be a plain number literal here — there is no row to
|
|
@@ -232,7 +233,7 @@ const VALUE_KEY = "__oqx_value";
|
|
|
232
233
|
// Rows as values (spec/surface §1.4, 1.2). The engine hands back store rows
|
|
233
234
|
// wherever the projection made a row a VALUE — a nested `collect { }` /
|
|
234
235
|
// `first { }` / `single { }` with an empty projection ("the row itself",
|
|
235
|
-
// spec/oqx §12), a `values` projection of `$it
|
|
236
|
+
// spec/oqx §12), a `values` projection of `$it`, a field bound to a
|
|
236
237
|
// row — and a store row is not a wire shape (column names, `attrs` as a JSON
|
|
237
238
|
// string, the `__path` join column, Buffers). Walk the projected value and
|
|
238
239
|
// render every tagged row as `{ id, path }` — the hit envelope's own keys
|