aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-07 14:49:06 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-07 14:49:06 -0700
commit502b43f00904967d9679b208a08beb764ce8911e (patch)
tree47576effb0de5fdaf717e62e22fd0ae1cb431462
parent90881c5841c49a2e56662b6d32e8058dfb1aa8b7 (diff)
downloadrails-502b43f00904967d9679b208a08beb764ce8911e.tar.gz
rails-502b43f00904967d9679b208a08beb764ce8911e.tar.bz2
rails-502b43f00904967d9679b208a08beb764ce8911e.zip
joins are starting to work better
-rw-r--r--lib/arel/table.rb4
-rw-r--r--spec/arel/table_spec.rb14
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb
index 7811c217a7..434f19cc6b 100644
--- a/lib/arel/table.rb
+++ b/lib/arel/table.rb
@@ -30,14 +30,14 @@ module Arel
nil
end
- def join relation
+ def join relation, klass = Nodes::InnerJoin
sm = SelectManager.new(@engine)
case relation
when String, Nodes::SqlLiteral
raise if relation.blank?
sm.from Nodes::StringJoin.new(self, relation)
else
- sm.from Nodes::InnerJoin.new(self, relation, nil)
+ sm.from klass.new(self, relation, nil)
end
end
diff --git a/spec/arel/table_spec.rb b/spec/arel/table_spec.rb
index 2ea45dcca1..78705b4f0a 100644
--- a/spec/arel/table_spec.rb
+++ b/spec/arel/table_spec.rb
@@ -12,6 +12,20 @@ module Arel
check @relation.joins(nil).should == nil
end
end
+
+ describe 'join' do
+ it 'takes a second argument for join type' do
+ right = @relation.alias
+ predicate = @relation[:id].eq(right[:id])
+ mgr = @relation.join(right, Nodes::OuterJoin).on(predicate)
+
+ mgr.to_sql.should be_like %{
+ SELECT FROM "users"
+ OUTER JOIN "users" "users_2"
+ ON "users"."id" = "users_2"."id"
+ }
+ end
+ end
end
describe 'alias' do