Commit 67c29ee
`applyFormulaPlan` computes Field.formula virtual fields after find/findOne,
but evaluated each expression with only `{ record }`. So a formula using
now()/today() ran against a fresh wall-clock read on every evaluation (no
determinism), and a formula referencing the caller (os.user.id / os.org.id)
faulted and fell back to null because user/org were never in scope.
Build the eval context the same way applyFieldDefaults already does: a `now`
snapshot pinned once per operation (every row + every formula field in one
read observes the same instant) plus os.user / os.org resolved from the
ExecutionContext. The two call sites in find()/findOne() pass opCtx.context.
Independent of timezone; the read-path prerequisite for ADR-0053 Phase 2
(#1980 will additionally thread `timezone` here once ExecutionContext.timezone
exists).
Tests: read-time formula resolves os.user.id/os.org.id from context; `now()`
is pinned identically across all rows in one find. Full objectql suite green
(639). Closes #1979.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 134043a commit 67c29ee
3 files changed
Lines changed: 97 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
514 | 573 | | |
515 | 574 | | |
516 | 575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
89 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
90 | 113 | | |
91 | 114 | | |
92 | 115 | | |
93 | | - | |
| 116 | + | |
94 | 117 | | |
95 | 118 | | |
96 | 119 | | |
| |||
1866 | 1889 | | |
1867 | 1890 | | |
1868 | 1891 | | |
1869 | | - | |
| 1892 | + | |
1870 | 1893 | | |
1871 | 1894 | | |
1872 | 1895 | | |
| |||
1932 | 1955 | | |
1933 | 1956 | | |
1934 | 1957 | | |
1935 | | - | |
| 1958 | + | |
1936 | 1959 | | |
1937 | 1960 | | |
1938 | 1961 | | |
| |||
0 commit comments