Fix DataQuery::applyRelation for multiple relations of the same class (fixes #3546)