mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
7f856c3c8d
This slightly change the code in the Arel to allow +/-INFINITY as open
ended since the Active Record expects that behavior. See 5ecbeda
.
50 lines
1.2 KiB
Ruby
50 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Arel # :nodoc: all
|
|
module Nodes
|
|
class Casted < Arel::Nodes::NodeExpression # :nodoc:
|
|
attr_reader :val, :attribute
|
|
def initialize(val, attribute)
|
|
@val = val
|
|
@attribute = attribute
|
|
super()
|
|
end
|
|
|
|
def nil?; @val.nil?; end
|
|
|
|
def hash
|
|
[self.class, val, attribute].hash
|
|
end
|
|
|
|
def eql?(other)
|
|
self.class == other.class &&
|
|
self.val == other.val &&
|
|
self.attribute == other.attribute
|
|
end
|
|
alias :== :eql?
|
|
end
|
|
|
|
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)
|
|
case other
|
|
when Arel::Nodes::Node, Arel::Attributes::Attribute, Arel::Table, Arel::Nodes::BindParam, Arel::SelectManager, Arel::Nodes::Quoted, Arel::Nodes::SqlLiteral
|
|
other
|
|
else
|
|
case attribute
|
|
when Arel::Attributes::Attribute
|
|
Casted.new other, attribute
|
|
else
|
|
Quoted.new other
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|