Fix database error when id has a space in it