aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors/test_to_sql.rb
diff options
context:
space:
mode:
authorTim Pope <code@tpope.net>2013-02-19 11:44:31 -0500
committerTim Pope <code@tpope.net>2013-02-19 12:37:13 -0500
commit0df9ab8442fc4a33b1962a49cebd66a3d1b0faf5 (patch)
tree51b237a199ef94cc89da8da8f396ff3b6580b119 /test/visitors/test_to_sql.rb
parent80f11e342d00a2177dd8e5684914855b87771c5b (diff)
downloadrails-0df9ab8442fc4a33b1962a49cebd66a3d1b0faf5.tar.gz
rails-0df9ab8442fc4a33b1962a49cebd66a3d1b0faf5.tar.bz2
rails-0df9ab8442fc4a33b1962a49cebd66a3d1b0faf5.zip
Support Float::INFINITY in ranges
Diffstat (limited to 'test/visitors/test_to_sql.rb')
-rw-r--r--test/visitors/test_to_sql.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index 08cf4566d1..d3e4dae963 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -230,6 +230,23 @@ module Arel
}
end
+ it 'can handle ranges bounded by infinity' do
+ node = @attr.in 1..Float::INFINITY
+ @visitor.accept(node).must_be_like %{
+ "users"."id" >= 1
+ }
+ node = @attr.in(-Float::INFINITY..3)
+ @visitor.accept(node).must_be_like %{
+ "users"."id" <= 3
+ }
+ node = @attr.in(-Float::INFINITY...3)
+ @visitor.accept(node).must_be_like %{
+ "users"."id" < 3
+ }
+ node = @attr.in(-Float::INFINITY..Float::INFINITY)
+ @visitor.accept(node).must_be_like %{1=1}
+ end
+
it 'can handle subqueries' do
table = Table.new(:users)
subquery = table.project(:id).where(table[:name].eq('Aaron'))
@@ -316,6 +333,23 @@ module Arel
}
end
+ it 'can handle ranges bounded by infinity' do
+ node = @attr.not_in 1..Float::INFINITY
+ @visitor.accept(node).must_be_like %{
+ "users"."id" < 1
+ }
+ node = @attr.not_in(-Float::INFINITY..3)
+ @visitor.accept(node).must_be_like %{
+ "users"."id" > 3
+ }
+ node = @attr.not_in(-Float::INFINITY...3)
+ @visitor.accept(node).must_be_like %{
+ "users"."id" >= 3
+ }
+ node = @attr.not_in(-Float::INFINITY..Float::INFINITY)
+ @visitor.accept(node).must_be_like %{1=0}
+ end
+
it 'can handle subqueries' do
table = Table.new(:users)
subquery = table.project(:id).where(table[:name].eq('Aaron'))