From 4cb02380116b102142f85d92b7923c11882f94c7 Mon Sep 17 00:00:00 2001 From: Stephen Prater & Fire-Dragon-DoL Date: Wed, 31 Jul 2013 01:08:22 +0200 Subject: Added right and full outer joins --- test/visitors/test_depth_first.rb | 12 ++++++++++++ test/visitors/test_join_sql.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'test/visitors') diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb index cbaa780dae..baa8f64184 100644 --- a/test/visitors/test_depth_first.rb +++ b/test/visitors/test_depth_first.rb @@ -81,12 +81,24 @@ module Arel assert_equal [:a, :b, join], @collector.calls end + def test_full_outer_join + join = Nodes::FullOuterJoin.new :a, :b + @visitor.accept join + assert_equal [:a, :b, join], @collector.calls + end + def test_outer_join join = Nodes::OuterJoin.new :a, :b @visitor.accept join assert_equal [:a, :b, join], @collector.calls end + def test_right_outer_join + join = Nodes::RightOuterJoin.new :a, :b + @visitor.accept join + assert_equal [:a, :b, join], @collector.calls + end + [ Arel::Nodes::Assignment, Arel::Nodes::Between, diff --git a/test/visitors/test_join_sql.rb b/test/visitors/test_join_sql.rb index ea71c05d79..34378dafe7 100644 --- a/test/visitors/test_join_sql.rb +++ b/test/visitors/test_join_sql.rb @@ -25,6 +25,19 @@ module Arel end end + describe 'FULL outer join' do + it 'should visit left if left is a join' do + t = Table.new :users + sm = t.select_manager + sm.join(t, Nodes::FullOuterJoin).on(t[:id]).join( + t, Nodes::FullOuterJoin).on(t[:id]) + sm.join_sql.must_be_like %{ + FULL OUTER JOIN "users" ON "users"."id" + FULL OUTER JOIN "users" ON "users"."id" + } + end + end + describe 'outer join' do it 'should visit left if left is a join' do t = Table.new :users @@ -37,6 +50,19 @@ module Arel } end end + + describe 'right outer join' do + it 'should visit left if left is a join' do + t = Table.new :users + sm = t.select_manager + sm.join(t, Nodes::RightOuterJoin).on(t[:id]).join( + t, Nodes::RightOuterJoin).on(t[:id]) + sm.join_sql.must_be_like %{ + RIGHT OUTER JOIN "users" ON "users"."id" + RIGHT OUTER JOIN "users" ON "users"."id" + } + end + end end end end -- cgit v1.2.3