From 97fe106724836564968cb91ee7974c97a0ea9826 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 6 Sep 2024 18:42:22 +0200 Subject: [PATCH] [apex] Verify OperationWithLimitsInLoop for triggers --- .../xml/OperationWithLimitsInLoop.xml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/OperationWithLimitsInLoop.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/OperationWithLimitsInLoop.xml index 6079c4e408..f036d63992 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/OperationWithLimitsInLoop.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/OperationWithLimitsInLoop.xml @@ -519,4 +519,27 @@ public class Foo { ]]> + + + SOQL inside loop in trigger (#5138) + 1 + 6 + tasks = new List(); + for (DataGeneratorStep__e event : Trigger.New) { + GenerateDataTask__c task = [SELECT Id, TaskStatus__c FROM GenerateDataTask__c WHERE Id=:event.SObjectId__c LIMIT 1]; + + if (task.TaskStatus__c != 'CREATED_ORDERS') { + task.TaskStatus__c = event.Status__c; + tasks.add(task); + } + } + + update tasks; +} +]]> +