Module: JSONAPI::ActiveRelation::Adapters::JoinLeftActiveRecordAdapter
- Defined in:
- lib/jsonapi/active_relation/adapters/join_left_active_record_adapter.rb
Instance Method Summary collapse
-
#joins_left(*columns) ⇒ Object
(also: #join_left)
Extends left_joins functionality to rails 4, and uses the same logic for rails 5.0.x and 5.1.x The default left_joins logic of rails 5.2.x is used.
Instance Method Details
#joins_left(*columns) ⇒ Object Also known as: join_left
Extends left_joins functionality to rails 4, and uses the same logic for rails 5.0.x and 5.1.x The default left_joins logic of rails 5.2.x is used. This results in and extra join in some cases. For example Post.joins(:comments).joins_left(comments: :author) will join the comments table twice, once inner and once left in 5.2, but only as inner in earlier versions.
10 11 12 13 14 15 16 17 |
# File 'lib/jsonapi/active_relation/adapters/join_left_active_record_adapter.rb', line 10 def joins_left(*columns) if Rails::VERSION::MAJOR >= 6 || (Rails::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 2) left_joins(columns) else join_dependency = ActiveRecord::Associations::JoinDependency.new(self, columns, []) joins(join_dependency) end end |