Created
June 8, 2012 16:15
-
-
Save mjgallag/2896541 to your computer and use it in GitHub Desktop.
BUG FIXED! Type.forName Specific SObject List Summer '12 (25.0) Week of June 4th Patch Regression Bug
This file contains hidden or 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
| // Per Rich Unger should be fixed in Week of June 11th Patch - https://twitter.com/rich_unger/status/210844950722641920 | |
| System.assert(Type.forName('List<' + Account.SObjectType.getDescribe().getName() + '>').newInstance() instanceOf Account[]); | |
| // Workaround (slightly less efficient) | |
| static Map<String, SObject[]> listInstancesBySObjectNames = new Map<String, SObject[]>{}; | |
| static SObject[] newListInstance(SObjectType sObjectType) { | |
| if (!listInstancesBySObjectNames.containsKey(sObjectType.getDescribe().getName())) | |
| listInstancesBySObjectNames.put(sObjectType.getDescribe().getName(), | |
| Database.query('SELECT Id FROM ' + sObjectType.getDescribe().getName() + ' WHERE Id = null')); | |
| return listInstancesBySObjectNames.get(SObjectType.getDescribe().getName()).clone(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment