Fix SQL errors when using a blob as a search criterion