You need to sign in to do that
Don't have an account?

What does a SOQL query return if no row is found
How do I check if a valid Contact is returned from a query like this in Apex.
Contact o = [SELECT c.Id, Email, LastName, FirstName, MailingCity, HomePhone, MailingState, MailingStreet, MailingPostalCode, AccountId, Source_Code__c, Drupal_User_Id__c FROM Contact c WHERE c.Email = :n.Email AND c.Id != :n.Id limit 1];
How do I check to see if o is a populate Contact object.
The query will return a QueryException.
You'll get "List has no rows to assign to sObject".
Well if you want to be exact then you get back.
Hm. Getting some inconsistent answers. So do I expect to catch an exception or can I assign it to a list and check the size?
Using the code snippet I posted will work.
You will only get the exception if you attempt to assign the results of the query to a single value rather than a list. In the example in your first post there would be an exception if no contact was found because you are assigning to a Contact variable.
For example, this causes an exception when there are no results:
Account res = [select name from account where createddate > 2012-12-31T23:59:59Z limit 1]; // no results, causes exception
While this does not:
List<Account> res = [select name from account where createddate > 2012-12-31T23:59:59Z];
System.debug(res.size()); // Outputs 0.
Either. Depends on your preference.
I tried your code.
Getting the error "Method does not exist or incorrect signature: void size() ".
Can you suggest something?