Class: Prequel::Relations::InnerJoin
- Defined in:
- lib/prequel/relations/inner_join.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
- #columns ⇒ Object
- #get_table(name) ⇒ Object
-
#initialize(left_operand, right_operand, predicate) ⇒ InnerJoin
constructor
A new instance of InnerJoin.
- #table_ref(query) ⇒ Object
- #visit(query) ⇒ Object
Methods inherited from Relation
#find, #get_column, #join, #project, #query, #singular_table_ref, #to_relation, #where
Constructor Details
#initialize(left_operand, right_operand, predicate) ⇒ InnerJoin
Returns a new instance of InnerJoin.
6 7 8 9 |
# File 'lib/prequel/relations/inner_join.rb', line 6 def initialize(left_operand, right_operand, predicate) @left, @right = left_operand.to_relation, right_operand.to_relation @predicate = resolve(predicate.to_predicate) end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
4 5 6 |
# File 'lib/prequel/relations/inner_join.rb', line 4 def left @left end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
4 5 6 |
# File 'lib/prequel/relations/inner_join.rb', line 4 def predicate @predicate end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
4 5 6 |
# File 'lib/prequel/relations/inner_join.rb', line 4 def right @right end |
Instance Method Details
#columns ⇒ Object
15 16 17 18 19 |
# File 'lib/prequel/relations/inner_join.rb', line 15 def columns (left.columns + right.columns).map do |column| derive(column) end end |
#get_table(name) ⇒ Object
11 12 13 |
# File 'lib/prequel/relations/inner_join.rb', line 11 def get_table(name) left.get_table(name) || right.get_table(name) end |
#table_ref(query) ⇒ Object
28 29 30 |
# File 'lib/prequel/relations/inner_join.rb', line 28 def table_ref(query) Sql::InnerJoinedTableRef.new(left.table_ref(query), right.singular_table_ref(query), predicate.resolve_in_query(query)) end |
#visit(query) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/prequel/relations/inner_join.rb', line 21 def visit(query) query.table_ref = table_ref(query) query.select_list = columns.map do |derived_column| query.resolve_derived_column(derived_column, :qualified) end end |