fix #2360 and CreateQuery