Fix bad match in query upgrade