Fix a bug with query error