aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-29 14:26:53 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-29 14:26:53 -0800
commit4b91cbc688b2fdc09a4a67a018c6bcb773934ea1 (patch)
tree6599e615242e3c4ecda65e9db465804ced80842a
parent61e0280b5d5cd36a5340ba8478d0bc1c9c5fea41 (diff)
downloadrails-4b91cbc688b2fdc09a4a67a018c6bcb773934ea1.tar.gz
rails-4b91cbc688b2fdc09a4a67a018c6bcb773934ea1.tar.bz2
rails-4b91cbc688b2fdc09a4a67a018c6bcb773934ea1.zip
adding select statement support
-rw-r--r--lib/arel/visitors/depth_first.rb9
-rw-r--r--test/visitors/test_depth_first.rb18
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb
index 5c89ef96b3..534f9edaf5 100644
--- a/lib/arel/visitors/depth_first.rb
+++ b/lib/arel/visitors/depth_first.rb
@@ -70,6 +70,15 @@ module Arel
@block.call o
end
+ def visit_Arel_Nodes_SelectStatement o
+ visit o.cores
+ visit o.orders
+ visit o.limit
+ visit o.lock
+ visit o.offset
+ @block.call o
+ end
+
def visit_Arel_Nodes_UpdateStatement o
visit o.relation
visit o.values
diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb
index a318583e26..04c5096f5b 100644
--- a/test/visitors/test_depth_first.rb
+++ b/test/visitors/test_depth_first.rb
@@ -102,6 +102,24 @@ module Arel
:e,
core], @collector.calls
end
+
+ def test_select_statement
+ ss = Nodes::SelectStatement.new
+ ss.cores.replace [:a]
+ ss.orders << :b
+ ss.limit = :c
+ ss.lock = :d
+ ss.offset = :e
+
+ @visitor.accept ss
+ assert_equal [
+ :a, ss.cores,
+ :b, ss.orders,
+ :c,
+ :d,
+ :e,
+ ss], @collector.calls
+ end
end
end
end