Module: Babik::QuerySet::Join
- Defined in:
- lib/babik/queryset/lib/join/join.rb,
lib/babik/queryset/lib/join/association_joiner.rb
Overview
Join between two tables
Defined Under Namespace
Classes: AbstractJoin, AssociationJoiner, LeftJoin, OriginTable, TargetTable
Class Method Summary collapse
-
.new_from_association(association, association_position, origin_table_alias, join = LeftJoin) ⇒ LeftJoin
Construct a new Join from an association.
Class Method Details
.new_from_association(association, association_position, origin_table_alias, join = LeftJoin) ⇒ LeftJoin
Construct a new Join from an association
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/babik/queryset/lib/join/join.rb', line 14 def self.new_from_association(association, association_position, origin_table_alias, join = LeftJoin) owner_table = association.active_record.table_name target_table_alias = "#{owner_table}__#{association.name}_#{association_position}" join_keys = association.join_keys target_table = TargetTable.new(association.table_name, target_table_alias, join_keys.key) origin_table = OriginTable.new(origin_table_alias, join_keys.foreign_key) join.new(target_table, origin_table) end |