Normally, to select things we use SOQL code like:
[
SELECT Id, Blah1__c, Blah2__c, Blah3__c
FROM Yada_Yada_Yada__c
WHERE Id IN :idSet
];
When we do this, the compiler (and our IDEs) will tell us if the variables, fields, or sobjects are somehow incorrect.
For a Batchable implementation, we would like to use a Database.QueryLocator.
However, the corresponding expression to get the Database.QueryLocator looks like:
Database.getQueryLocator(
'SELECT Id, Blah1__c, Blah2__c, Blah3__c '
+ ' FROM Yada_Yada_Yada__c '
+ ' WHERE Id IN :idSet '
);
Now, nothing is typesafe. My compiler won't alert me if I've named anything wrong. My IDE won't help me if I rename "idSet" later. SFDC won't stop anyone from renaming or deleting the SObject or SObject fields.
Obviously I could use the SOQL query to get a list and then create an iterable, but this would bring back the undesirable governor limit.
Is there any typesafe way to get a Database.QueryLocator?