diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/predications.rb | 12 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 8 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb index 78cd87d430..1941383068 100644 --- a/lib/arel/predications.rb +++ b/lib/arel/predications.rb @@ -31,7 +31,7 @@ module Arel when Range if other.begin == -Float::INFINITY if other.end == Float::INFINITY - Nodes::NotIn.new self, [] + Nodes::NotIn.new self, [] elsif other.exclude_end? Nodes::LessThan.new(self, Nodes.build_quoted(other.end, self)) else @@ -67,20 +67,20 @@ module Arel Arel::Nodes::NotIn.new(self, other.ast) when Range if other.begin == -Float::INFINITY # The range begins with negative infinity - if other.end == Float::INFINITY + if other.end == Float::INFINITY Nodes::In.new self, [] # The range is infinite, so return an empty range elsif other.exclude_end? Nodes::GreaterThanOrEqual.new(self, Nodes.build_quoted(other.end, self)) else Nodes::GreaterThan.new(self, Nodes.build_quoted(other.end, self)) end - elsif other.end == Float::INFINITY + elsif other.end == Float::INFINITY Nodes::LessThan.new(self, Nodes.build_quoted(other.begin, self)) else left = Nodes::LessThan.new(self, Nodes.build_quoted(other.begin, self)) if other.exclude_end? right = Nodes::GreaterThanOrEqual.new(self, Nodes.build_quoted(other.end, self)) - else + else right = Nodes::GreaterThan.new(self, Nodes.build_quoted(other.end, self)) end Nodes::Or.new left, right @@ -149,7 +149,7 @@ module Arel end def lt right - Nodes::LessThan.new self, right + Nodes::LessThan.new self, Nodes.build_quoted(right, self) end def lt_any others @@ -161,7 +161,7 @@ module Arel end def lteq right - Nodes::LessThanOrEqual.new self, right + Nodes::LessThanOrEqual.new self, Nodes.build_quoted(right, self) end def lteq_any others diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 8c63070084..ae1b7930af 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -436,8 +436,12 @@ module Arel end def visit_Arel_Nodes_Grouping o, collector - collector << "(" - visit(o.expr, collector) << ")" + if o.expr.is_a? Nodes::Grouping + visit(o.expr, collector) + else + collector << "(" + visit(o.expr, collector) << ")" + end end def visit_Arel_SelectManager o, collector |