@@ -81,6 +81,7 @@ public class TriggerScriptTest extends BaseWebDriverTest
8181 private static final String AFTER_DELETE_ERROR = "This is the After Delete Error" ;
8282
8383 private static final String MANAGED_STRUCT_ADD_ERROR = "attempted to add" ;
84+ private static final String MANAGED_STRUCT_REMOVE_ERROR = "attempted to remove" ;
8485
8586 //Dataset constants
8687 private static final String STUDY_SCHEMA = "study" ;
@@ -372,13 +373,20 @@ public void testListManagedColumnsTriggers() throws Exception
372373 insCmd .addRow (Map .of ("Name" , "Managed Struct" , "SSN" , "111222335" , "Company" , "Test Co" ));
373374 assertAPIErrorMessage (insCmd , MANAGED_STRUCT_ADD_ERROR , cn );
374375
376+ // Insert: structural remove error — trigger deletes a column not declared as managed
377+ insCmd = new InsertRowsCommand (LIST_SCHEMA , LIST_NAME );
378+ insCmd .addRow (Map .of ("Name" , "Managed Struct Remove" , "SSN" , "111222336" , "Company" , "Test Co" ));
379+ assertAPIErrorMessage (insCmd , MANAGED_STRUCT_REMOVE_ERROR , cn );
380+
375381 // Setup: insert rows for update tests; include "employeeId" in payload so insert validation passes
376382 insCmd = new InsertRowsCommand (LIST_SCHEMA , LIST_NAME );
377383 insCmd .addRow (Map .of ("Name" , "MC Update Setup" , "SSN" , "111222340" , "Company" , "Setup Co" , "employeeId" , "OLD-ID" ));
378384 insCmd .addRow (Map .of ("Name" , "MC Struct Setup" , "SSN" , "111222341" , "Company" , "Setup Co" , "employeeId" , "OLD-ID-2" ));
385+ insCmd .addRow (Map .of ("Name" , "MC Struct Remove Setup" , "SSN" , "111222342" , "Company" , "Setup Co" , "employeeId" , "OLD-ID-3" ));
379386 resp = insCmd .execute (cn , getProjectName ());
380387 Integer updateKey = (Integer ) resp .getRows ().getFirst ().get ("Key" );
381388 Integer structKey = (Integer ) resp .getRows ().get (1 ).get ("Key" );
389+ Integer structRemoveKey = (Integer ) resp .getRows ().get (2 ).get ("Key" );
382390
383391 // Update: trigger sets both declared managed columns "company" and "employeeId"
384392 UpdateRowsCommand updCmd = new UpdateRowsCommand (LIST_SCHEMA , LIST_NAME );
@@ -389,15 +397,21 @@ public void testListManagedColumnsTriggers() throws Exception
389397 Assert .assertEquals ("Trigger should have set employeeId" , "EMP-UPD" , updated .employeeId );
390398
391399 // Update: declared managed column not set by trigger
392- // "employeeId" is absent from the payload; trigger has no handler for this name and never sets it
400+ // "boomerang" is absent from the payload; SSN="-123" causes the trigger to skip setting it
401+ // Name is explicitly provided so the trigger does not accidentally match a named handler
393402 updCmd = new UpdateRowsCommand (LIST_SCHEMA , LIST_NAME );
394- updCmd .addRow (Map .of ("Key" , updateKey , "SSN" , "-123" , "Company" , "Test Co" ));
403+ updCmd .addRow (Map .of ("Key" , updateKey , "Name" , "MC Update Setup" , " SSN" , "-123" , "Company" , "Test Co" ));
395404 assertAPIErrorMessage (updCmd , "declared the managed column 'boomerang'" , cn );
396405
397406 // Update: structural add error — trigger adds a column not declared as managed
398407 updCmd = new UpdateRowsCommand (LIST_SCHEMA , LIST_NAME );
399408 updCmd .addRow (Map .of ("Key" , structKey , "Name" , "Managed Struct" , "SSN" , "111222341" ));
400409 assertAPIErrorMessage (updCmd , MANAGED_STRUCT_ADD_ERROR , cn );
410+
411+ // Update: structural remove error — trigger deletes a column not declared as managed
412+ updCmd = new UpdateRowsCommand (LIST_SCHEMA , LIST_NAME );
413+ updCmd .addRow (Map .of ("Key" , structRemoveKey , "Name" , "Managed Struct Remove" , "SSN" , "111222342" ));
414+ assertAPIErrorMessage (updCmd , MANAGED_STRUCT_REMOVE_ERROR , cn );
401415 }
402416
403417 /** Issue 52098 - ensure trigger scripts have a chance to do custom type conversion with the incoming row */
0 commit comments