Capture query before it is modified.