I found a pretty surprising change in platform behavior today.
Minimum Viable Reproduction (MVR)
It's simple to reproduce. Just run this script in
Account a = [SELECT Id FROM Account LIMIT 1]; a.Phone = '1111111111'; system.debug(a.Name);
There should be an uncaught exception.
Execute Anonymous Error
Line: 3, Column: 1
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Account.Name
There is no exception, but the field is seen as null.
Is this an intentional change, or a bug that was introduced as part of Spring 17? Or was it introduced in an earlier release and I just didn't notice?
I considered it obvious based on the M in Minimum Viable Reproduction, but I should be explicit that I already discovered the behavior is still as expected if you don't set any fields. It seems that setting a field is what causes the change in behavior.
Account a = [SELECT Id FROM Account LIMIT 1]; system.debug(a.Name); // still throws