fix(automation): record-change flows see multi-lookup fields + array-index interpolation (#1872)#1915
Merged
Merged
Conversation
…index interpolation (#1872) A `multiple: true` lookup is an array column a driver may not echo back on create, so it was absent from the after-create record a record-change flow saw: `record.target_channels != null` was false and `{rec.target_channels.0}` resolved empty. (Multi-lookup is an array column, not a junction table.) Two parts: - trigger-record-change buildContext: read the hook's `input.data` (objectql's actual insert/update payload key — it had been reading a non-existent `input.doc`, so the input fallback never worked) and overlay the after-row on it, so fields the driver didn't return stay visible to the flow's start condition and `{record.<field>}` interpolation. - service-automation template: `{var.path.N}` numeric segments index into arrays (`{record.channels.0}`). Tests: full-kernel repro (driver that doesn't echo the array column → flow fires on the multi-lookup condition AND stamps `{record.target_channels.0}`) + array-index interpolation unit tests. service-automation 199, trigger 20 pass (incl. the #1491 integration test, confirming the input.data change is safe). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1872.
Problem (confirmed via full-kernel repro)
A
multiple: truelookup is stored as an array column (not a junction table — objectql has no junction logic; the expand path atengine.tsalready treats the value asArray.isArray). A data driver may not echo that column back oncreate, so it was absent from the after-create record the record-change flow sees:record.target_channels != nullevaluated false → the flow never ran;{piece.target_channels.0}interpolation resolved empty.Root cause (two distinct gaps, both confirmed by instrumented repro)
buildContextreadctx.input.**doc**, but objectql lifecycle hooks carry the written row underctx.input.**data**(insert/update). So the input fallback was always undefined — the flow only ever saw the driver's (incomplete) after-row..0segment ({rec.channels.0}) never matched the fast path.Fix
@objectstack/trigger-record-change—buildContextreadsinput.dataand overlays the after-row on it ({ ...inputData, ...after }): the after-row wins for every field the driver returns (id, DB-computed), and fields it omits (multi-lookup arrays) come from the input. Affects only record-change flows.@objectstack/service-automation—{var.path.N}numeric segments now index into arrays (template.ts), so{record.channels.0}resolves.Tests
record-after-createflow gated onrecord.target_channels != nullfires AND itsupdate_recordstamps{record.target_channels.0}(=ch_1). Fails on each gap before the fix; passes after.@objectstack/service-automation199 pass,@objectstack/trigger-record-change20 pass (incl. the Record-change trigger plugin loads but flows never fire on data writes (7.4.1) #1491 integration test — confirms theinput.datachange doesn't regress the record path).🤖 Generated with Claude Code