aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/arel/visitors/depth_first.rb1
-rw-r--r--lib/arel/visitors/dot.rb1
-rw-r--r--lib/arel/visitors/to_sql.rb1
-rw-r--r--test/visitors/test_depth_first.rb8
-rw-r--r--test/visitors/test_to_sql.rb5
5 files changed, 16 insertions, 0 deletions
diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb
index 4d2ecfa5e1..eab20ac831 100644
--- a/lib/arel/visitors/depth_first.rb
+++ b/lib/arel/visitors/depth_first.rb
@@ -164,6 +164,7 @@ module Arel
def visit_Array o
o.each { |i| visit i }
end
+ alias :visit_Set :visit_Array
def visit_Hash o
o.each { |k,v| visit(k); visit(v) }
diff --git a/lib/arel/visitors/dot.rb b/lib/arel/visitors/dot.rb
index f0cefeabd7..12cce1e266 100644
--- a/lib/arel/visitors/dot.rb
+++ b/lib/arel/visitors/dot.rb
@@ -216,6 +216,7 @@ module Arel
edge(i) { visit x }
end
end
+ alias :visit_Set :visit_Array
def visit_edge o, method
edge(method) { visit o.send(method) }
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index ca09373b64..095aa5279a 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -752,6 +752,7 @@ module Arel
def visit_Array o, collector
inject_join o, collector, ", "
end
+ alias :visit_Set :visit_Array
def quote value, column = nil
return value if Arel::Nodes::SqlLiteral === value
diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb
index baa8f64184..d50ea3e59a 100644
--- a/test/visitors/test_depth_first.rb
+++ b/test/visitors/test_depth_first.rb
@@ -1,4 +1,5 @@
require 'helper'
+require 'set'
module Arel
module Visitors
@@ -171,6 +172,13 @@ module Arel
assert_equal [:a, :b, node, list], @collector.calls
end
+ def test_set
+ node = Nodes::Or.new(:a, :b)
+ set = Set.new([node])
+ @visitor.accept set
+ assert_equal [:a, :b, node, set], @collector.calls
+ end
+
def test_hash
node = Nodes::Or.new(:a, :b)
hash = { node => node }
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index c03d89cfef..d84142e27a 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -1,4 +1,5 @@
require 'helper'
+require 'set'
module Arel
module Visitors
@@ -228,6 +229,10 @@ module Arel
compile(Nodes.build_quoted({:a => 1}))
end
+ it "should visit_Set" do
+ @visitor.accept Set.new([1, 2])
+ end
+
it "should visit_BigDecimal" do
compile Nodes.build_quoted(BigDecimal.new('2.14'))
end