S
Sharon Rosner
Sequel version 0.1.5 has just been released. This release adds support
for multiple joins (thanks Farrel Lifson) and now supports left outer,
right outer, full outer and inner joins.
Multiple joins
==============
Datasets now support multiple joins. Note that join conditions can be
in the form of a hash of correlating fields between the two tables, or
a field name on the joined table that is correlated to the id field in
the first table.
DB[:a].joinb, :a_id).joinc, :b_id).sql #=>
"SELECT * FROM a LEFT OUTER JOIN b ON (b.a_id = a.id) LEFT OUTER JOIN
c ON (c.b_id = b.id)"
Join types
==========
Datasets now contain support for left outer, right outer, full outer
and inner joins. You can specify the join type by using either the
Dataset#join_table method:
DB[:a].join_tableinner, :b, :a_id)
Or by using one of the specific join methods:
DB[:a].left_outer_joinb, :a_id)
DB[:a].right_outer_joinb, :a_id)
DB[:a].full_outer_joinb, :a_id)
DB[:a].inner_joinb, :a_id)
Also note that Dataset#join is an alias for Dataset#left_outer_join,
which is probably the most common join type.
======================
Sequel documentation:
<http://sequel.rubyforge.org>
Join the Sequel-talk group:
<http://groups.google.com/group/sequel-talk>
Install the gem:
sudo gem install sequel
Or check out the source and install manually:
svn co http://ruby-sequel.googlecode.com/svn/trunk sequel
cd sequel
rake install
for multiple joins (thanks Farrel Lifson) and now supports left outer,
right outer, full outer and inner joins.
Multiple joins
==============
Datasets now support multiple joins. Note that join conditions can be
in the form of a hash of correlating fields between the two tables, or
a field name on the joined table that is correlated to the id field in
the first table.
DB[:a].joinb, :a_id).joinc, :b_id).sql #=>
"SELECT * FROM a LEFT OUTER JOIN b ON (b.a_id = a.id) LEFT OUTER JOIN
c ON (c.b_id = b.id)"
Join types
==========
Datasets now contain support for left outer, right outer, full outer
and inner joins. You can specify the join type by using either the
Dataset#join_table method:
DB[:a].join_tableinner, :b, :a_id)
Or by using one of the specific join methods:
DB[:a].left_outer_joinb, :a_id)
DB[:a].right_outer_joinb, :a_id)
DB[:a].full_outer_joinb, :a_id)
DB[:a].inner_joinb, :a_id)
Also note that Dataset#join is an alias for Dataset#left_outer_join,
which is probably the most common join type.
======================
Sequel documentation:
<http://sequel.rubyforge.org>
Join the Sequel-talk group:
<http://groups.google.com/group/sequel-talk>
Install the gem:
sudo gem install sequel
Or check out the source and install manually:
svn co http://ruby-sequel.googlecode.com/svn/trunk sequel
cd sequel
rake install