From 5b6daff5b6d5439e07c058718069f54b34970f93 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 14 Jan 2019 13:22:54 +0900 Subject: Use `unboundable?` rather than `boundable?` The `unboundable?` behaves like the `infinite?`. ```ruby inf = Topic.predicate_builder.build_bind_attribute(:id, Float::INFINITY) inf.infinite? # => 1 oob = Topic.predicate_builder.build_bind_attribute(:id, 9999999999999999999999999999999) oob.unboundable? # => 1 inf = Topic.predicate_builder.build_bind_attribute(:id, -Float::INFINITY) inf.infinite? # => -1 oob = Topic.predicate_builder.build_bind_attribute(:id, -9999999999999999999999999999999) oob.unboundable? # => -1 ``` --- activerecord/lib/arel/visitors/to_sql.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/arel/visitors/to_sql.rb') diff --git a/activerecord/lib/arel/visitors/to_sql.rb b/activerecord/lib/arel/visitors/to_sql.rb index b5a960ce68..c08403eea9 100644 --- a/activerecord/lib/arel/visitors/to_sql.rb +++ b/activerecord/lib/arel/visitors/to_sql.rb @@ -576,7 +576,7 @@ module Arel # :nodoc: all def visit_Arel_Nodes_In(o, collector) if Array === o.right && !o.right.empty? - o.right.keep_if { |value| boundable?(value) } + o.right.delete_if { |value| unboundable?(value) } end if Array === o.right && o.right.empty? @@ -590,7 +590,7 @@ module Arel # :nodoc: all def visit_Arel_Nodes_NotIn(o, collector) if Array === o.right && !o.right.empty? - o.right.keep_if { |value| boundable?(value) } + o.right.delete_if { |value| unboundable?(value) } end if Array === o.right && o.right.empty? @@ -812,8 +812,8 @@ module Arel # :nodoc: all } end - def boundable?(value) - !value.respond_to?(:boundable?) || value.boundable? + def unboundable?(value) + value.respond_to?(:unboundable?) && value.unboundable? end def has_join_sources?(o) -- cgit v1.2.3