fixed a SQL error for not required reference fields where no value was selected