Add type cast on type mismatch when using fields in clauses.