As a Salesforce Apex developer, it is frequently desirable to have a QueryLocator instead of a List in order to overcome certain governor limits.
Moreover, for a variety of reasons, it can be preferable to use inline SOQL instead of dynamic SOQL to obtain the QueryLocator.
Usually if we use the [SELECT ...] syntax, we will get back a List.
But -- surprisingly -- if we do
for (Account account : [SELECT Id, ... FROM Account ...]) {
// Whatever
}
or
Database.getQueryLocator([SELECT Id, ... FROM Account ...]);
Salesforce provides a QueryLocator instead of the List which might be expected.
Are there other contexts in which we can use this notation to get a QueryLocator?