def apply_join_dependency(relation, join_dependency)
for association in join_dependency.join_associations
relation = association.join_relation(relation)
end
limitable_reflections = using_limitable_reflections?(join_dependency.reflections)
if !limitable_reflections && relation.limit_value
limited_id_condition = construct_limited_ids_condition(relation.except(:select))
relation = relation.where(limited_id_condition)
end
relation = relation.except(:limit, :offset) unless limitable_reflections
relation
end