Issue#668 Blank STI type blows up search with Postgres

Use combination of COALESCE and NULLIF to ensure that table rows with
blank string for type are cast to parent class