Fix incorrect relation query.