[apex] Verify nested subqueries work (#5218)

Fixes #5218
This commit is contained in:
Andreas Dangel 2024-09-19 17:26:28 +02:00
parent 36c1738135
commit 909e86ca99
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
4 changed files with 26 additions and 0 deletions

View File

@ -20,6 +20,7 @@ This is a {{ site.pmd.release_type }} release.
(ApexCRUDViolation, CognitiveComplexity, OperationWithLimitsInLoop)
* [#5163](https://github.com/pmd/pmd/issues/5163): \[apex] Parser error when using toLabel in SOSL query
* [#5182](https://github.com/pmd/pmd/issues/5182): \[apex] Parser error when using GROUPING in a SOQL query
* [#5218](https://github.com/pmd/pmd/issues/5218): \[apex] Parser error when using nested subqueries in SOQL
* core
* [#5059](https://github.com/pmd/pmd/issues/5059): \[core] xml output doesn't escape CDATA inside its own CDATA
* [#5201](https://github.com/pmd/pmd/issues/5201): \[core] PMD sarif schema file points to nonexistent location

View File

@ -94,4 +94,12 @@ class ApexTreeDumpTest extends BaseTreeDumpTest {
void triggersWithMethods() {
doTest("TriggerWithMethod");
}
/**
* @see <a href="https://github.com/pmd/pmd/issues/5218">[apex] Parser error when using nested subqueries in SOQL</a>
*/
@Test
void nestedSubqueries() {
doTest("NestedSubqueries");
}
}

View File

@ -0,0 +1,5 @@
public with sharing class NestedSubqueries {
public NestedSubqueries() {
Schema.Account account = [SELECT Id, (SELECT Id, (SELECT Id FROM CaseComments) FROM Cases) FROM Account LIMIT 1];
}
}

View File

@ -0,0 +1,12 @@
+- ApexFile[@DefiningType = "NestedSubqueries", @RealLoc = true]
+- UserClass[@DefiningType = "NestedSubqueries", @Image = "NestedSubqueries", @InterfaceNames = (), @Nested = false, @RealLoc = true, @SimpleName = "NestedSubqueries", @SuperClassName = ""]
+- ModifierNode[@Abstract = false, @DefiningType = "NestedSubqueries", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 1, @Override = false, @Private = false, @Protected = false, @Public = true, @RealLoc = true, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = true, @WithoutSharing = false]
+- Method[@Arity = 0, @CanonicalName = "<init>", @Constructor = true, @DefiningType = "NestedSubqueries", @Image = "NestedSubqueries", @RealLoc = true, @ReturnType = "void", @StaticInitializer = false]
+- ModifierNode[@Abstract = false, @DefiningType = "NestedSubqueries", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 1, @Override = false, @Private = false, @Protected = false, @Public = true, @RealLoc = true, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
+- BlockStatement[@CurlyBrace = true, @DefiningType = "NestedSubqueries", @RealLoc = true]
+- VariableDeclarationStatements[@DefiningType = "NestedSubqueries", @RealLoc = true]
+- ModifierNode[@Abstract = false, @DefiningType = "NestedSubqueries", @DeprecatedTestMethod = false, @Final = false, @Global = false, @InheritedSharing = false, @Modifiers = 0, @Override = false, @Private = false, @Protected = false, @Public = false, @RealLoc = false, @Static = false, @Test = false, @TestOrTestSetup = false, @Transient = false, @Virtual = false, @WebService = false, @WithSharing = false, @WithoutSharing = false]
+- VariableDeclaration[@DefiningType = "NestedSubqueries", @Image = "account", @RealLoc = true, @Type = "Schema.Account"]
+- SoqlExpression[@CanonicalQuery = "SELECT Id, (SELECT Id, (SELECT Id FROM CaseComments) FROM Cases) FROM Account LIMIT 1", @DefiningType = "NestedSubqueries", @Query = "SELECT Id, (SELECT Id, (SELECT Id FROM CaseComments) FROM Cases) FROM Account LIMIT 1", @RealLoc = true]
+- VariableExpression[@DefiningType = "NestedSubqueries", @Image = "account", @RealLoc = true]
+- EmptyReferenceExpression[@DefiningType = null, @RealLoc = false]