Fix query in edit mode