One of the most basic and versatile sObject methods is get. For example:
My_Object__c record = [SELECT Name FROM My_Object__c LIMIT 1];
system.assertNotEquals(null, record.get('Name'));
However, this function no longer seems to work on Custom Settings unless I query for them explicitly. At least there is one checkbox field (among many) on my Custom Setting that is returning null.
final String EXISTING_NAME = 'Some Name that exists';
My_Custom_Setting__c recordByQuery = [
SELECT SomeBoolean__c
FROM My_Custom_Setting__c
WHERE Name = :EXISTING_NAME];
My_Custom_Setting__c recordByGetAll = My_Custom_Setting__c.getAll().get(EXISTING_NAME);
My_Custom_Setting__c recordByGetInstance = My_Custom_Setting__c.getInstance(EXISTING_NAME);
system.assertEquals(true, recordByQuery.SomeBoolean__c); // succeeds
system.assertEquals(true, recordByGetAll.SomeBoolean__c); // succeeds
system.assertEquals(true, recordByGetInstance.SomeBoolean__c); // succeeds
system.assertEquals(true, recordByQuery.get('SomeBoolean__c')); // succeeds
system.assertEquals(true, recordByGetAll.get('SomeBoolean__c')); // fails (null)
system.assertEquals(true, recordByGetInstance.get('SomeBoolean__c')); // fails (null)
Should I report this as a bug? I am pretty sure this just stopped working, and that it should work. Has anyone else run into this issue?