Fix query error