module Jennifer::QueryBuilder::Joining
Direct including types
Defined in:
jennifer/query_builder/joining.crInstance Method Summary
-
#join(source : Class, table_alias : String? = nil, type = :inner, relation : String? = nil, &)
Adds
JOINof the source's class table to the request. -
#join(source : String, table_alias : String? = nil, type = :inner, relation : String? = nil, &)
Adds
JOINof source table to the request. -
#join(source : Query, table_alias : String, type = :inner, &)
Adds
JOINof source query to the request. -
#lateral_join(source : Query, table_alias : String, type = :inner, &)
Adds
JOIN LATERALof source query to the request. -
#left_join(source : Class, table_alias : String? = nil, &)
Adds
LEFT JOINof the source's class table to the request. -
#left_join(source : String, table_alias : String? = nil, &)
Adds
LEFT JOINof source table to the request. -
#right_join(source : Class, table_alias : String? = nil, &)
Adds
RIGHT JOINof the source's class table to the request. - #right_join(source : String, table_alias : String? = nil, &)
Instance Method Detail
Adds JOIN of the source's class table to the request.
You can pass table alias which will be automatically used by given expression builder.
Method block provides two arguments:
- expression builder for the table that is mentioned in the
FROMclause; - expression builder for the table that is joined.
At the same time block is executed in context of joined table.
Contact.all.join(Address) { |t| _contact_id == t._id }
# => JOIN addresses ON addresses.contact_id = contacts.id
Contact.all.join(Address, "some_table") { |t| _contact_id == t._id }
# => JOIN addresses some_table ON some_table.contact_id = contacts.id
Adds JOIN of source table to the request.
Contact.all.join("addresses") { |t| _contact_id == t._id }
# => JOIN addresses ON addresses.contact_id = contacts.id
Adds JOIN of source query to the request.
Contact.all.join(Address.all, "some_table") { |t| _contact_id == t._id }
# => JOIN (SELECT addresses.* FROM addresses) some_table ON some_table.contact_id = contacts.id
Adds JOIN LATERAL of source query to the request.
Contact.all.lateral_join(Address.all, "some_table") { |t| _contact_id == t._id }
# => JOIN LATERAL (SELECT addresses.* FROM addresses) some_table ON some_table.contact_id = contacts.id
Adds LEFT JOIN of the source's class table to the request.
Alias for #join(source, table_alias, :left).
Adds LEFT JOIN of source table to the request.
Alias for #join(source, table_alias, :left).
Adds RIGHT JOIN of the source's class table to the request.
Alias for #join(source, table_alias, :right).
Adds RIGHT JOIN of source table to the request.
Alias for #join(source, table_alias, :right).