aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-13 13:08:42 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-13 13:08:42 +0530
commit83592292768de6c093eea06289470154761f3825 (patch)
tree08521cda150bd63d0c8149c370ee5458166f1169
parent182c5a0e1f6a2268557ca43ed953d23b32e0483f (diff)
downloadrails-83592292768de6c093eea06289470154761f3825.tar.gz
rails-83592292768de6c093eea06289470154761f3825.tar.bz2
rails-83592292768de6c093eea06289470154761f3825.zip
Make sure string join relations can be chained
-rw-r--r--lib/arel/algebra/relations/operations/join.rb4
-rw-r--r--spec/arel/engines/sql/unit/relations/join_spec.rb31
2 files changed, 34 insertions, 1 deletions
diff --git a/lib/arel/algebra/relations/operations/join.rb b/lib/arel/algebra/relations/operations/join.rb
index e9320f28e1..df457686cc 100644
--- a/lib/arel/algebra/relations/operations/join.rb
+++ b/lib/arel/algebra/relations/operations/join.rb
@@ -47,6 +47,10 @@ module Arel
class InnerJoin < Join; end
class OuterJoin < Join; end
class StringJoin < Join
+ def externalizable?
+ relation1.externalizable?
+ end
+
def attributes
relation1.externalize.attributes
end
diff --git a/spec/arel/engines/sql/unit/relations/join_spec.rb b/spec/arel/engines/sql/unit/relations/join_spec.rb
index e2fc4bab3d..b926c2aaab 100644
--- a/spec/arel/engines/sql/unit/relations/join_spec.rb
+++ b/spec/arel/engines/sql/unit/relations/join_spec.rb
@@ -103,7 +103,36 @@ module Arel
})
end
end
- end
+
+ it "passes the string when there are multiple string joins" do
+ relation = StringJoin.new(@relation1, "INNER JOIN asdf ON fdsa")
+ relation = StringJoin.new(relation, "INNER JOIN lifo ON fifo")
+ sql = StringJoin.new(relation, "INNER JOIN hatful ON hallow").to_sql
+
+ adapter_is :mysql do
+ sql.should be_like(%Q{
+ SELECT `users`.`id`, `users`.`name`
+ FROM `users`
+ INNER JOIN asdf ON fdsa
+ INNER JOIN lifo ON fifo
+ INNER JOIN hatful ON hallow
+ })
+ end
+
+ adapter_is_not :mysql do
+ sql.should be_like(%Q{
+ SELECT "users"."id", "users"."name"
+ FROM "users"
+ INNER JOIN asdf ON fdsa
+ INNER JOIN lifo ON fifo
+ INNER JOIN hatful ON hallow
+ })
+ end
+ end
+
+ end
+
+
end
end
end