diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/visitors/test_depth_first.rb | 1 | ||||
-rw-r--r-- | test/visitors/test_mysql.rb | 18 | ||||
-rw-r--r-- | test/visitors/test_to_sql.rb | 10 |
3 files changed, 27 insertions, 2 deletions
diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb index 1a72789f83..81220b63a4 100644 --- a/test/visitors/test_depth_first.rb +++ b/test/visitors/test_depth_first.rb @@ -103,6 +103,7 @@ module Arel [ Arel::Nodes::Assignment, Arel::Nodes::Between, + Arel::Nodes::Concat, Arel::Nodes::DoesNotMatch, Arel::Nodes::Equality, Arel::Nodes::GreaterThan, diff --git a/test/visitors/test_mysql.rb b/test/visitors/test_mysql.rb index 8e4b9e6861..30dcea3d36 100644 --- a/test/visitors/test_mysql.rb +++ b/test/visitors/test_mysql.rb @@ -55,6 +55,24 @@ module Arel compile(node).must_be_like "LOCK IN SHARE MODE" end end + + describe "concat" do + it "concats columns" do + @table = Table.new(:users) + query = @table[:name].concat(@table[:name]) + compile(query).must_be_like %{ + CONCAT("users"."name", "users"."name") + } + end + + it "concats a string" do + @table = Table.new(:users) + query = @table[:name].concat(Nodes.build_quoted('abc')) + compile(query).must_be_like %{ + CONCAT("users"."name", 'abc') + } + end + end end end end diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index ea58039529..4162d970b5 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -469,13 +469,19 @@ module Arel compile(node).must_equal %(("products"."price" - 7)) end + it "should handle Concatination" do + table = Table.new(:users) + node = table[:name].concat(table[:name]) + compile(node).must_equal %("users"."name" || "users"."name") + end + it "should handle arbitrary operators" do node = Arel::Nodes::InfixOperation.new( - '||', + '&&', Arel::Attributes::String.new(Table.new(:products), :name), Arel::Attributes::String.new(Table.new(:products), :name) ) - compile(node).must_equal %("products"."name" || "products"."name") + compile(node).must_equal %("products"."name" && "products"."name") end end |