aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors
diff options
context:
space:
mode:
authorKeenan Brock <keenan@thebrocks.net>2015-12-31 20:22:07 -0500
committerKeenan Brock <keenan@thebrocks.net>2016-01-05 21:27:48 -0500
commit83c47c1962827698eb0ed58d191f121cedf89385 (patch)
treee19640d2eabfeabad80c61a95a589a8b42d56703 /test/visitors
parentdfd22638c2773d843ea1d2e56992a6ac355b3ecb (diff)
downloadrails-83c47c1962827698eb0ed58d191f121cedf89385.tar.gz
rails-83c47c1962827698eb0ed58d191f121cedf89385.tar.bz2
rails-83c47c1962827698eb0ed58d191f121cedf89385.zip
Add database specific string concatenation
Diffstat (limited to 'test/visitors')
-rw-r--r--test/visitors/test_depth_first.rb1
-rw-r--r--test/visitors/test_mysql.rb18
-rw-r--r--test/visitors/test_to_sql.rb10
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