Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure string join relations can be chained

  • Loading branch information...
commit 83592292768de6c093eea06289470154761f3825 1 parent 182c5a0
@lifo lifo authored
View
4 lib/arel/algebra/relations/operations/join.rb
@@ -47,6 +47,10 @@ def engine
class InnerJoin < Join; end
class OuterJoin < Join; end
class StringJoin < Join
+ def externalizable?
+ relation1.externalizable?
+ end
+
def attributes
relation1.externalize.attributes
end
View
31 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
Please sign in to comment.
Something went wrong with that request. Please try again.