I need to write a SOQL query that retrieves all accounts with the character '\u0000'
, i.e. the null character, in their name. I wrote the following code:
final string nullChar = '\u0000';
final string nullCharSearch = '%' + nullChar + '%';
Database.QueryLocator = Database.getQueryLocator(
'select name from Account where name like :nullCharSearch'
);
However, this does not return any results. Our Account table is very large so it is difficult for me to confirm whether there are indeed no results, or if my query is not behaving correctly. So, the question is, will this code produce the correct results, or do I need to escape or hardcode the unicode?
\u0000\uFFFD\uFFFD
). As for why it's allowed, our requirement is such that we have to keep the data even if it's bad data. I suppose our developers could have used URL encoding, but hindsight is 20/20.