Fix 500 with postgres in badge search.