Fixed bug when editing queries with an order