Created
August 27, 2016 14:49
-
-
Save zaynelt/7394745ec8b46ed04e8d575942d05d2e to your computer and use it in GitHub Desktop.
illustrating a bug in system.debug()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class SystemDotDebugWeirdness { | |
//this is copied from the WeekFiveHomework class--slightly modified to just zoom in on the issue we | |
//were looking at in class | |
public static void soqlPractice () { | |
//Query for accounts | |
List < Account > topFiveAccounts = [SELECT ID, Name, AnnualRevenue FROM Account WHERE AnnualRevenue !=0]; | |
system.debug('This should be 5: '+topFiveAccounts.size()); | |
//Query for Opportunity--and the related Account's name | |
List<Opportunity> myOpps = new List<Opportunity>([SELECT Id, Opportunity.Account.Name, StageName FROM Opportunity WHERE AccountId IN :topFiveAccounts]); | |
//Weird--the account name isn't showing up here... | |
system.debug(myOpps); | |
for(Opportunity o: myOpps){ | |
//BUT IT IS SHOWING UP HERE! | |
system.debug(o.Account.Name); | |
} | |
//SO--we're finding that system.debug has some limits... | |
//...sad trombone sounds... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment