Uh oh!
There was an error while loading. Please reload this page.
Triggers: support managing columns for data iteration - #7541
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
labkey-matthewb
left a comment
There was a problem hiding this comment.
Considerations for additional features (do we want to do now or never)?
- Support different managed columns for insert/update
- Support in JavaScript triggers
Uh oh!
There was an error while loading. Please reload this page.
1d28e80 to
3e9e24fCompareUh oh!
There was an error while loading. Please reload this page.
labkey-nicka
commented
Apr 3, 2026
Implemented both of these. |
7096977 to
5ff3f06Compare61286bc to
3e70d27CompareUh oh!
There was an error while loading. Please reload this page.
labkey-matthewb
left a comment
There was a problem hiding this comment.
I like the error checking, and merging in the values for the managed columns early is an interesting idea that probably greatly reduces the chance of losing data.
labkey-matthewb
left a comment
There was a problem hiding this comment.
One small suggestion. I like the strict error checking.
3e70d27 to
faf395cCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- no longer process non-data iterator pathway for managed columns
846c2c9 to
8625910CompareUh oh!
There was an error while loading. Please reload this page.
| if (insertOption != null && insertOption.mergeRows && existingRecord == null) | ||
| throw new IllegalArgumentException("An existing record must be supplied for all MERGE triggers"); | ||
| setManagedColumns(newRow, null, TableInfo.TriggerType.INSERT); |
There was a problem hiding this comment.
Should pass through existingRecord?
| if (managedColumns == null) | ||
| continue; | ||
| if (insertOption.updateOnly) |
There was a problem hiding this comment.
Probably worth adding a comment about why this is correct/consistent
Uh oh!
There was an error while loading. Please reload this page.
Rationale
When query triggers are called within data iterators they are allowed to manipulate the data of the row that is being procured. However, if a trigger modifies the columns (i.e., the keys of the row map) it can result in data being mismanaged due to the columns in the row not aligning with what the data iterator specified.
This introduces the notion of "managed" columns to triggers. Triggers can, at the outset, declare which columns they are going to manage. Any managed columns are then picked up by the data iterator during initialization to ensure they are persisted correctly. To enforce this management more strictly, and to avoid mismanagement of null values, triggers are required to fulfill all managed column values by either clearing the value or setting the value. After the trigger has fired the resulting row will be validated and checked. The result is consistent enforcement and acknowledgement of triggers that manipulate the shape of the data.
Related Pull Requests
User Education Handoff
@labkey-steveh
For developer teams that have implemented trigger scripts that are using beforeInsert() or beforeUpdate(), and are modifying the shape of the data by adding or removing columns (i.e., altering the keys of the row map), they will need to implement managed Columns:
https://www.labkey.org/Documentation/wiki-page.view?name=serverSideValidation#managedColumns
If they have a lot of these, they can turn on the experimental feature flag: Disable managed columns in query triggers
Changes
TableInfo.getTriggerManagedColumns()to allow for data iterator to gather all managed columnssetInsertManagedColumns()andsetUpdateManagedColumns())Tasks
Manual Testing notes (in progress)