diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-03 09:46:42 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-08 16:45:17 +0900 |
commit | 7f856c3c8db71e2600d6a84bbc6510eb4ddd0418 (patch) | |
tree | 0a88d5d29152838ecc9495e784f5b6e68aa2b725 /activerecord/lib/arel/nodes | |
parent | a75dea08225285eec5fc199684cd1a51853d2845 (diff) | |
download | rails-7f856c3c8db71e2600d6a84bbc6510eb4ddd0418.tar.gz rails-7f856c3c8db71e2600d6a84bbc6510eb4ddd0418.tar.bz2 rails-7f856c3c8db71e2600d6a84bbc6510eb4ddd0418.zip |
Consolidate the duplicated code that building range predicate
This slightly change the code in the Arel to allow +/-INFINITY as open
ended since the Active Record expects that behavior. See 5ecbeda.
Diffstat (limited to 'activerecord/lib/arel/nodes')
-rw-r--r-- | activerecord/lib/arel/nodes/bind_param.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/arel/nodes/casted.rb | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/arel/nodes/bind_param.rb b/activerecord/lib/arel/nodes/bind_param.rb index ba8340558a..f145e44ae3 100644 --- a/activerecord/lib/arel/nodes/bind_param.rb +++ b/activerecord/lib/arel/nodes/bind_param.rb @@ -24,6 +24,10 @@ module Arel # :nodoc: all value.nil? end + def infinite? + value.respond_to?(:infinite?) && value.infinite? + end + def boundable? !value.respond_to?(:boundable?) || value.boundable? end diff --git a/activerecord/lib/arel/nodes/casted.rb b/activerecord/lib/arel/nodes/casted.rb index c1e6e97d6d..6e911b717d 100644 --- a/activerecord/lib/arel/nodes/casted.rb +++ b/activerecord/lib/arel/nodes/casted.rb @@ -27,6 +27,10 @@ module Arel # :nodoc: all class Quoted < Arel::Nodes::Unary # :nodoc: alias :val :value def nil?; val.nil?; end + + def infinite? + value.respond_to?(:infinite?) && value.infinite? + end end def self.build_quoted(other, attribute = nil) |