From 7832cd3bb3c6cfd76fdb63ca75995f2e6c87757c Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 29 Jun 2011 13:45:26 -0700 Subject: fix depth first visitor to support ascending and descending nodes --- History.txt | 6 ++++++ lib/arel/visitors/depth_first.rb | 2 ++ test/test_select_manager.rb | 9 +++++++++ 3 files changed, 17 insertions(+) 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 -- cgit v1.2.3