Skip to content

Commit a857bf5

Browse files
committed
Review feedback, remove manageColumns flag
- no longer process non-data iterator pathway for managed columns
1 parent c2246ad commit a857bf5

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

src/org/labkey/test/tests/TriggerScriptTest.java

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -389,40 +389,41 @@ public void testListManagedColumnsTriggers() throws Exception
389389
insCmd.addRow(Map.of("Name", "Managed Struct Remove", "SSN", "111222336", "Company", "Test Co"));
390390
assertAPIErrorMessage(insCmd, MANAGED_STRUCT_REMOVE_ERROR, cn);
391391

392+
// TODO: Test update via DIB -- how is this invoked? Via file only?
392393
// Setup: insert rows for update tests; include "employeeId" in payload so insert validation passes
393-
insCmd = new InsertRowsCommand(LIST_SCHEMA, LIST_NAME);
394-
insCmd.addRow(Map.of("Name", "MC Update Setup", "SSN", "111222340", "Company", "Setup Co", "employeeId", "OLD-ID"));
395-
insCmd.addRow(Map.of("Name", "MC Struct Setup", "SSN", "111222341", "Company", "Setup Co", "employeeId", "OLD-ID-2"));
396-
insCmd.addRow(Map.of("Name", "MC Struct Remove Setup", "SSN", "111222342", "Company", "Setup Co", "employeeId", "OLD-ID-3"));
397-
resp = insCmd.execute(cn, getProjectName());
398-
Integer updateKey = (Integer) resp.getRows().getFirst().get("Key");
399-
Integer structKey = (Integer) resp.getRows().get(1).get("Key");
400-
Integer structRemoveKey = (Integer) resp.getRows().get(2).get("Key");
401-
402-
// Update: trigger sets both declared managed columns "company" and "employeeId"
403-
UpdateRowsCommand updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
404-
updCmd.addRow(Map.of("Key", updateKey, "Name", "Managed Update", "SSN", "111222340"));
405-
resp = updCmd.execute(cn, getProjectName());
406-
EmployeeRecord updated = EmployeeRecord.fromMap(resp.getRows().getFirst());
407-
Assert.assertEquals("Trigger should have set company", "Managed Co", updated.company);
408-
Assert.assertEquals("Trigger should have set employeeId", "EMP-UPD", updated.employeeId);
409-
410-
// Update: declared managed column not set by trigger
411-
// "boomerang" is absent from the payload; SSN="-123" causes the trigger to skip setting it
412-
// Name is explicitly provided so the trigger does not accidentally match a named handler
413-
updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
414-
updCmd.addRow(Map.of("Key", updateKey, "Name", "MC Update Setup", "SSN", "-123", "Company", "Test Co"));
415-
assertAPIErrorMessage(updCmd, "declared the managed column 'boomerang'", cn);
416-
417-
// Update: structural add error — trigger adds a column not declared as managed
418-
updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
419-
updCmd.addRow(Map.of("Key", structKey, "Name", "Managed Struct", "SSN", "111222341"));
420-
assertAPIErrorMessage(updCmd, MANAGED_STRUCT_ADD_ERROR, cn);
421-
422-
// Update: structural remove error — trigger deletes a column not declared as managed
423-
updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
424-
updCmd.addRow(Map.of("Key", structRemoveKey, "Name", "Managed Struct Remove", "SSN", "111222342"));
425-
assertAPIErrorMessage(updCmd, MANAGED_STRUCT_REMOVE_ERROR, cn);
394+
// insCmd = new InsertRowsCommand(LIST_SCHEMA, LIST_NAME);
395+
// insCmd.addRow(Map.of("Name", "MC Update Setup", "SSN", "111222340", "Company", "Setup Co", "employeeId", "OLD-ID"));
396+
// insCmd.addRow(Map.of("Name", "MC Struct Setup", "SSN", "111222341", "Company", "Setup Co", "employeeId", "OLD-ID-2"));
397+
// insCmd.addRow(Map.of("Name", "MC Struct Remove Setup", "SSN", "111222342", "Company", "Setup Co", "employeeId", "OLD-ID-3"));
398+
// resp = insCmd.execute(cn, getProjectName());
399+
// Integer updateKey = (Integer) resp.getRows().getFirst().get("Key");
400+
// Integer structKey = (Integer) resp.getRows().get(1).get("Key");
401+
// Integer structRemoveKey = (Integer) resp.getRows().get(2).get("Key");
402+
//
403+
// // Update: trigger sets both declared managed columns "company" and "employeeId"
404+
// UpdateRowsCommand updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
405+
// updCmd.addRow(Map.of("Key", updateKey, "Name", "Managed Update", "SSN", "111222340"));
406+
// resp = updCmd.execute(cn, getProjectName());
407+
// EmployeeRecord updated = EmployeeRecord.fromMap(resp.getRows().getFirst());
408+
// Assert.assertEquals("Trigger should have set company", "Managed Co", updated.company);
409+
// Assert.assertEquals("Trigger should have set employeeId", "EMP-UPD", updated.employeeId);
410+
//
411+
// // Update: declared managed column not set by trigger
412+
// // "boomerang" is absent from the payload; SSN="-123" causes the trigger to skip setting it
413+
// // Name is explicitly provided so the trigger does not accidentally match a named handler
414+
// updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
415+
// updCmd.addRow(Map.of("Key", updateKey, "Name", "MC Update Setup", "SSN", "-123", "Company", "Test Co"));
416+
// assertAPIErrorMessage(updCmd, "declared the managed column 'boomerang'", cn);
417+
//
418+
// // Update: structural add error — trigger adds a column not declared as managed
419+
// updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
420+
// updCmd.addRow(Map.of("Key", structKey, "Name", "Managed Struct", "SSN", "111222341"));
421+
// assertAPIErrorMessage(updCmd, MANAGED_STRUCT_ADD_ERROR, cn);
422+
//
423+
// // Update: structural remove error — trigger deletes a column not declared as managed
424+
// updCmd = new UpdateRowsCommand(LIST_SCHEMA, LIST_NAME);
425+
// updCmd.addRow(Map.of("Key", structRemoveKey, "Name", "Managed Struct Remove", "SSN", "111222342"));
426+
// assertAPIErrorMessage(updCmd, MANAGED_STRUCT_REMOVE_ERROR, cn);
426427
}
427428

428429
/** Issue 52098 - ensure trigger scripts have a chance to do custom type conversion with the incoming row */
@@ -694,6 +695,10 @@ private void doManagedColumnsTriggerTest(String schemaName, String queryName, St
694695
"Managed Struct Remove", "MC-SR-001"));
695696
assertAPIErrorMessage(insCmd, MANAGED_STRUCT_REMOVE_ERROR, cn);
696697

698+
// TODO: Test update via DIB -- how is this invoked? Via file only?
699+
if (DATASET_NAME.equals(queryName))
700+
return;
701+
697702
// Setup: insert rows for update tests with neutral Comments so the trigger fallback fires
698703
InsertRowsCommand setupCmd = new InsertRowsCommand(schemaName, queryName);
699704
setupCmd.addRow(makeSetupRow(keyColumnName, requiresDate, dispatchIsKey, "MC Update Setup", "MC-UPD-001"));

0 commit comments

Comments
 (0)