I've been working with Apex for a couple of months now and I still haven't figured this out. When does a SOQL query return a List of objects (even though it's just one object in the list) and when does it return an object?
For example, I have been using queries like this:
[SELECT Id, Name FROM Account WHERE Name = :search] or
[SELECT Value__c FROM System_Setting__c WHERE Name = :settingName]. And sometimes I can use an assignment directly to an object and some other times I need to use a list (even when I use a filter on Id or I use
LIMIT 1 to make sure there's only one record to return.