Repository navigation
fix(service-analytics): the draft preview resolves a { $field } comparand as the live faces do - #37299
Conversation
…rand as the live faces do Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As92T28dA9wc7wtu3iE
…s read Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As92T28dA9wc7wtu3iE
📓 Docs Drift CheckThis PR changes 1 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin f71dc78646a9a511aa63cf33baee7feebcdd5411 && git checkout f71dc78646a9a511aa63cf33baee7feebcdd5411
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 08bf7d2a41a754c601af90281446acf38c3169ec 8a7f8ff4cae36d39377e34d90dc36ecf2a501fc4 && git checkout -B drift-repro 08bf7d2a41a754c601af90281446acf38c3169ec && git merge --no-ff 8a7f8ff4cae36d39377e34d90dc36ecf2a501fc4
node scripts/docs-audit/affected-docs.mjs --json 08bf7d2a41a754c601af90281446acf38c3169ec
|
|
repo:objectstack#7 · os-alice · session_011y7As6JrAPNfuwC2RLXXGu
席位意见:ACCEPT,排队落地。 席位核对 — ACCEPT · head 8a7f8ff (2026-11-25T14:26Z)
|
Fixes #36677
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
The analytics draft preview (
queryDatasetwithpreviewDrafts) compared the row value against the{ $field }reference OBJECT, as text, so every field-to-field filter answered a wrong count with a 200. It now gives the live faces' answer:$eq$ne$gt$gte$lt$lte) the preview compares the row's two columns, with the shared cross-field corpus's truth table (both empty is equal,$neis the exact complement, an ordering needs both sides). New modulepreview-field-reference.ts; the arm sits inmatchesWhere.INVALID_FILTER/ 400, judged once before any row is read: a multi-value / JSON / file / formula column on either side and a cross-class pair (through@objectstack/spec'scrossFieldComparisonVerdict, the one classification driver-sql and the write check read), an undeclared column, a dotted path, and a reference in an$in/$ninlist or under a text-pattern operator (through this package's ownwhere-door sentences incomparand-shape.ts).{ $field, addDays }offset reference. The live faces shift a date/datetime referent in SQL; the only in-memory copy of that arithmetic is private to@objectstack/formula, which this package does not depend on, and a second copy here would be a second rule set. The preview refuses it by name, in its not-evaluated words. On the numeric pair the live faces refuse it too.Tests
src/__tests__/preview-field-reference-36677.test.ts, on the production composition (ObjectQL + SqlDriver on SQLite, six rows, one per truth-table cell):$eq/$ne/$gt(and$gte/$lt/$lte, a numeric pair,$not,$or, a self-reference): native, ObjectQL and preview counts all equal the native count (2 / 4 / 1 for the card's three);$eq/$neontagsand on aselectdeclaredmultiple, and the other refused shapes:codeINVALID_FILTERandstatus400 on all three faces;@objectstack/driver-sql: everyCROSS_FIELD_CASESrow through the preview's filters with the corpus's expected ids, everyCROSS_FIELD_REFUSALSrow refused except the two tenant-column rows (see Acceptance notes), every offset case refused by name, and the offset fixture's bare-reference controls served with their rows.Measured on origin/main e845656 before the change (native / objectql / preview)
Ablation (one-shot, not kept)
The new arm in
matchesWherereplaced byundefinedwithscripts/ablation-replace.mjs(anchor hit 1, injected text present 1): the 12 scalar pins went red (Tests 12 failed | 104 skipped), the card's scalar$eqpin among them. Restore proven by the script: blob after restore821f350cb98dequals the HEAD blob,git diff HEADempty. The subject is imported fromsrc/, so no rebuild leg applies.Package suite and typecheck
pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2on 9370100:Test Files 227 passed (227),Tests 5897 passed | 345 skipped (6242), exit 0.tsc --noEmit(the package'stypecheck): red on 9370100 with one TS2352 in the new test file; fixed in 8a7f8ff, re-run exit 0. The new pin file re-run on 8a7f8ff:Tests 116 passed (116).Acceptance notes
resolveTenantFieldName). The preview is handed a field's declared shape only (sourceFieldMeta), so{ label: { $eq: { $field: 'organization_id' } } }is still compared on the preview (measured: native 400, preview count 2). Closing it needs the tenant column handed to the service, a change to the exportedAnalyticsServiceConfigshape, which is outside this card's surface; raised in the report as an open question rather than guessed by name.codeandstatusmatch the live faces; the pins assert those, not the prose).Verification
Read first:
packages/services/service-analytics/src/preview-field-reference.ts(the refusal walk and the truth table), thematchesWherehunk inpreview-evaluator.ts, then the integration block of the test file.Two-minute check:
pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/preview-field-reference-36677.test.tsprintsTests 116 passed (116).Generated by Claude Code