aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-06-29 13:45:26 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-06-29 13:45:26 -0700
commit7832cd3bb3c6cfd76fdb63ca75995f2e6c87757c (patch)
tree08282ee1a942264114310efa2fbe2ba1a65cd301
parentda99e806703ff1e6b004dd0371b323df21d598e7 (diff)
downloadrails-7832cd3bb3c6cfd76fdb63ca75995f2e6c87757c.tar.gz
rails-7832cd3bb3c6cfd76fdb63ca75995f2e6c87757c.tar.bz2
rails-7832cd3bb3c6cfd76fdb63ca75995f2e6c87757c.zip
fix depth first visitor to support ascending and descending nodes
-rw-r--r--History.txt6
-rw-r--r--lib/arel/visitors/depth_first.rb2
-rw-r--r--test/test_select_manager.rb9
3 files changed, 17 insertions, 0 deletions
diff --git a/History.txt b/History.txt
index e9eed4e50a..ea27ae6d6d 100644
--- a/History.txt
+++ b/History.txt
@@ -1,3 +1,9 @@
+== 2.1.4 / unreleased
+
+* Bug Fixes
+
+ * Fix depth-first traversal to understand ascending / descending nodes.
+
== 2.1.3 / 2011-06-27
* Bug Fixues
diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb
index 6f9385de1b..43d186cc1a 100644
--- a/lib/arel/visitors/depth_first.rb
+++ b/lib/arel/visitors/depth_first.rb
@@ -23,6 +23,8 @@ module Arel
alias :visit_Arel_Nodes_Offset :unary
alias :visit_Arel_Nodes_On :unary
alias :visit_Arel_Nodes_Ordering :unary
+ alias :visit_Arel_Nodes_Ascending :unary
+ alias :visit_Arel_Nodes_Descending :unary
alias :visit_Arel_Nodes_Top :unary
alias :visit_Arel_Nodes_UnqualifiedColumn :unary
diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb
index e948aec131..119ad3ec4f 100644
--- a/test/test_select_manager.rb
+++ b/test/test_select_manager.rb
@@ -412,6 +412,15 @@ module Arel
ast = mgr.ast
mgr.visitor.accept(ast).must_equal mgr.to_sql
end
+ it 'should allow orders to work when the ast is grepped' do
+ table = Table.new :users
+ mgr = table.from table
+ mgr.project Arel.sql '*'
+ mgr.from table
+ mgr.orders << Arel::Nodes::Ascending.new(Arel.sql('foo'))
+ mgr.ast.grep(Arel::Nodes::OuterJoin)
+ mgr.to_sql.must_be_like %{ SELECT * FROM "users" ORDER BY foo ASC }
+ end
end
describe 'taken' do