I have a Junction object for which I'm trying retrieve records in a subquery from one of it's parents and strangely the query returns child records when executing the query in SOQL Query Editor but it returns blank if executed via Apes. Has anyone come across this before? It's the same user running the query both times.
SOQL query executed in QUERY Editor (which returns Partner Relations)
Select Id, Name, (SELECT ID, Request__c FROM Partner_Relations__r) FROM Request__c
The equivalent executed in Apex
System.debug('Hello what values ' + [Select Id, Name, (SELECT ID, Request__c FROM Partner_Relations__r) FROM Request__c]);
The Apex query returns
Request__c:{Id=a1R1q000001BkHoEAK, Name=R-0003238, RecordTypeId=0125I000000pEmgQAE, CurrencyIsoCode=USD}, Request__c:{Id=a1R1q000001BkHuEAK, Name=R-0003240, RecordTypeId=0125I000000pEmhQAE, CurrencyIsoCode=USD})
I haven't even queried RecordTypeId
or CurrencyISOCode
:)
Does anyone know why the child records would not return in Apex despite returning in a general SOQL Editor?
The above Apex is just a simplified example as run in Execute Anonymous. The full query was returning blank child records in a function I had also. As the same user runs both I was a bit confused :)
Thanks in advance for any pointers on why this may be occurring.