Skip to content

Commit 8625910

Browse files
committed
setInsertManagedColumns: supply table to determine supported operations
1 parent 7c0fe94 commit 8625910

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

api/src/org/labkey/api/data/triggers/Trigger.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ default boolean isManagedColumnsEnabled()
165165
* This method is a no-op when {@code insertOption} is {@code null}, which signals a non-data-iterator
166166
* operation where managed-column enforcement does not apply.
167167
*
168+
* @param table the table the trigger is operating on; used to determine the operations supported by the table
168169
* @param newRow the incoming row map to be inserted; modified in place to add missing managed columns
169170
* @param existingRecord the existing database row for MERGE operations; an empty map indicates no
170171
* matching row yet (new record); must be non-null when {@code insertOption.mergeRows} is true
171172
* @param insertOption the insert mode in effect, or {@code null} for non-data-iterator operations
172173
*/
173174
default void setInsertManagedColumns(
175+
@NotNull TableInfo table,
174176
Map<String, Object> newRow,
175177
@Nullable Map<String, Object> existingRecord,
176178
@Nullable QueryUpdateService.InsertOption insertOption
@@ -184,7 +186,7 @@ default void setInsertManagedColumns(
184186
// then throw an error to avoid overwriting managed values to null.
185187
// existingRow == null indicated the existing row was not queried, so throw an error
186188
// existingRecord.isEmpty() indicates a new record, so do not throw an error
187-
if (insertOption != null && insertOption.mergeRows && existingRecord == null)
189+
if (insertOption != null && existingRecord == null && insertOption.mergeRows && table.supportsInsertOption(insertOption))
188190
throw new IllegalArgumentException("An existing record must be supplied for all MERGE triggers");
189191

190192
setManagedColumns(newRow, existingRecord, TableInfo.TriggerType.INSERT);

0 commit comments

Comments
 (0)