diff options
author | Ernie Miller <ernie@metautonomo.us> | 2011-03-09 02:27:43 +0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-09 03:03:05 +0800 |
commit | 21e052796d3007488d5dd9f00299a3a22fdb6249 (patch) | |
tree | 10807b13b1af103dc961eeed5ce1a6ee73cde357 /test/visitors | |
parent | 2fc53bec29bb660e501cf350ae07506082dcb110 (diff) | |
download | rails-21e052796d3007488d5dd9f00299a3a22fdb6249.tar.gz rails-21e052796d3007488d5dd9f00299a3a22fdb6249.tar.bz2 rails-21e052796d3007488d5dd9f00299a3a22fdb6249.zip |
Replace MathOperation with InfixOperation to support more operators
Diffstat (limited to 'test/visitors')
-rw-r--r-- | test/visitors/test_to_sql.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index c47fd57a28..25ff7be3e2 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -194,7 +194,7 @@ module Arel end end - describe "Nodes::MathOperation" do + describe "Nodes::InfixOperation" do it "should handle Multiplication" do node = Arel::Attributes::Decimal.new(Table.new(:products), :price) * Arel::Attributes::Decimal.new(Table.new(:currency_rates), :rate) @visitor.accept(node).must_equal %("products"."price" * "currency_rates"."rate") @@ -214,6 +214,15 @@ module Arel node = Arel::Attributes::Decimal.new(Table.new(:products), :price) - 7 @visitor.accept(node).must_equal %(("products"."price" - 7)) end + + it "should handle arbitrary operators" do + node = Arel::Nodes::InfixOperation.new( + '||', + Arel::Attributes::String.new(Table.new(:products), :name), + Arel::Attributes::String.new(Table.new(:products), :name) + ) + @visitor.accept(node).must_equal %("products"."name" || "products"."name") + end end describe "Nodes::NotIn" do |