-
Notifications
You must be signed in to change notification settings - Fork 552
Closed
Description
I tried to create a query that also fetches related child records but I was unable as the syntax of building such subqueries doesn't produce correct SOQL. Even test methods from the library did work.
Account acct = new Account();
acct.Name = 'testchildqueriesacct';
insert acct;
Contact cont = new Contact();
cont.FirstName = 'test';
cont.LastName = 'test';
cont.AccountId = acct.Id;
insert cont;
String soql = new fflib_QueryFactory(Account.SObjectType)
.selectField('Name')
.subselectQuery(Contact.SObjectType)
.selectField('FirstName')
.toSoql();
System.debug(soql);
List<Account> accounts = Database.query(soql);
Prints out this incorrect soql
SELECT FirstName FROM Contacts
and throws this exception:
System.QueryException: sObject type 'Contacts' is not supported. If you are attempting to use a
custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the > describe call for the appropriate names.
Metadata
Metadata
Assignees
Labels
No labels