diff options
-rw-r--r-- | lib/arel/visitors/visitor.rb | 3 | ||||
-rw-r--r-- | test/visitors/test_oracle.rb | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/arel/visitors/visitor.rb b/lib/arel/visitors/visitor.rb index 055acf9765..85359f3e67 100644 --- a/lib/arel/visitors/visitor.rb +++ b/lib/arel/visitors/visitor.rb @@ -13,7 +13,8 @@ module Arel def visit object send DISPATCH[object.class], object - rescue NoMethodError + rescue NoMethodError => e + raise e if respond_to?(DISPATCH[object.class], true) warn "visiting #{object.class} via superclass, this will be removed in arel 2.2.0" if $VERBOSE superklass = object.class.ancestors.find { |klass| respond_to?(DISPATCH[klass], true) diff --git a/test/visitors/test_oracle.rb b/test/visitors/test_oracle.rb index 2c9bba15d8..c6fcb7134c 100644 --- a/test/visitors/test_oracle.rb +++ b/test/visitors/test_oracle.rb @@ -59,7 +59,7 @@ module Arel describe 'limit' do it 'adds a rownum clause' do stmt = Nodes::SelectStatement.new - stmt.limit = 10 + stmt.limit = Nodes::Limit.new(10) sql = @visitor.accept stmt sql.must_be_like %{ SELECT WHERE ROWNUM <= 10 } end @@ -67,7 +67,7 @@ module Arel it 'is idempotent' do stmt = Nodes::SelectStatement.new stmt.orders << Nodes::SqlLiteral.new('foo') - stmt.limit = 10 + stmt.limit = Nodes::Limit.new(10) sql = @visitor.accept stmt sql2 = @visitor.accept stmt sql.must_equal sql2 @@ -76,7 +76,7 @@ module Arel it 'creates a subquery when there is order_by' do stmt = Nodes::SelectStatement.new stmt.orders << Nodes::SqlLiteral.new('foo') - stmt.limit = 10 + stmt.limit = Nodes::Limit.new(10) sql = @visitor.accept stmt sql.must_be_like %{ SELECT * FROM (SELECT ORDER BY foo) WHERE ROWNUM <= 10 @@ -86,7 +86,7 @@ module Arel it 'creates a subquery when there is DISTINCT' do stmt = Nodes::SelectStatement.new stmt.cores.first.projections << Nodes::SqlLiteral.new('DISTINCT id') - stmt.limit = 10 + stmt.limit = Arel::Nodes::Limit.new(10) sql = @visitor.accept stmt sql.must_be_like %{ SELECT * FROM (SELECT DISTINCT id) WHERE ROWNUM <= 10 @@ -95,7 +95,7 @@ module Arel it 'creates a different subquery when there is an offset' do stmt = Nodes::SelectStatement.new - stmt.limit = 10 + stmt.limit = Nodes::Limit.new(10) stmt.offset = Nodes::Offset.new(10) sql = @visitor.accept stmt sql.must_be_like %{ @@ -110,7 +110,7 @@ module Arel it 'is idempotent with different subquery' do stmt = Nodes::SelectStatement.new - stmt.limit = 10 + stmt.limit = Nodes::Limit.new(10) stmt.offset = Nodes::Offset.new(10) sql = @visitor.accept stmt sql2 = @visitor.accept stmt |