What should I spect when the account is null in the below code?

SELECT Id, name, Account__c
FROM AccountChildren
WHERE Account__r.someField = true

I am having issues debugging the query and I would like to know what it is supposed to happen

  • 3
    Your query won't fail or give null pointer exceotion. Internally it would be translated to SELECT Id, name, Account__c FROM AccountChildren WHERE (Account__c!=null and Account__r.someField = true) – Pranay Jaiswal Apr 9 '18 at 13:14

As Pranay mentioned in the comments you will not see an error. You can easily test this by creating an Opportunity and not assigning an Account. Then run the following query in the Developer console:

SELECT Id, name, AccountId
FROM Opportunity
WHERE Account.Name ='test'


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.