method
build_join_buckets
v6.1.7.7 -
Show latest stable
-
0 notes -
Class: ActiveRecord::QueryMethods
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
build_join_buckets()
private
Hide source
# File activerecord/lib/active_record/relation/query_methods.rb, line 1212 def build_join_buckets buckets = Hash.new { |h, k| h[k] = [] } unless left_outer_joins_values.empty? stashed_left_joins = [] left_joins = select_association_list(left_outer_joins_values, stashed_left_joins) do raise ArgumentError, "only Hash, Symbol and Array are allowed" end if joins_values.empty? buckets[:association_join] = left_joins buckets[:stashed_join] = stashed_left_joins return buckets, Arel::Nodes::OuterJoin else stashed_left_joins.unshift construct_join_dependency(left_joins, Arel::Nodes::OuterJoin) end end joins = joins_values.dup if joins.last.is_a?(ActiveRecord::Associations::JoinDependency) stashed_eager_load = joins.pop if joins.last.base_klass == klass end joins.each_with_index do |join, i| joins[i] = Arel::Nodes::StringJoin.new(Arel.sql(join.strip)) if join.is_a?(String) end while joins.first.is_a?(Arel::Nodes::Join) join_node = joins.shift if !join_node.is_a?(Arel::Nodes::LeadingJoin) && (stashed_eager_load || stashed_left_joins) buckets[:join_node] << join_node else buckets[:leading_join] << join_node end end buckets[:association_join] = select_association_list(joins, buckets[:stashed_join]) do |join| if join.is_a?(Arel::Nodes::Join) buckets[:join_node] << join else raise "unknown class: %s" % join.class.name end end buckets[:stashed_join].concat stashed_left_joins if stashed_left_joins buckets[:stashed_join] << stashed_eager_load if stashed_eager_load return buckets, Arel::Nodes::InnerJoin end