Fix error when try to complete query and the related entity is not specified