diff options
author | Ernie Miller <ernie@metautonomo.us> | 2010-03-30 09:52:22 -0400 |
---|---|---|
committer | Ernie Miller <ernie@metautonomo.us> | 2010-05-07 13:05:55 -0400 |
commit | 0afcfa27c9f386ca7c190cd1f66db1cdd9971f3b (patch) | |
tree | cbb3edb878cdf7786705c4c586f1c23751cadb0b /lib/arel/engines/sql | |
parent | 7e7a3548bb7e024b0bac0a03e3ac9f774c3486d4 (diff) | |
download | rails-0afcfa27c9f386ca7c190cd1f66db1cdd9971f3b.tar.gz rails-0afcfa27c9f386ca7c190cd1f66db1cdd9971f3b.tar.bz2 rails-0afcfa27c9f386ca7c190cd1f66db1cdd9971f3b.zip |
Rename Attribute Not -> Inequality and add a Not predicate (complement)
Diffstat (limited to 'lib/arel/engines/sql')
-rw-r--r-- | lib/arel/engines/sql/predicates.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/arel/engines/sql/predicates.rb b/lib/arel/engines/sql/predicates.rb index 7fac09e750..29bc74c605 100644 --- a/lib/arel/engines/sql/predicates.rb +++ b/lib/arel/engines/sql/predicates.rb @@ -5,6 +5,16 @@ module Arel "#{operand1.to_sql} #{predicate_sql} #{operand1.format(operand2)}" end end + + class Unary < Predicate + def to_sql(formatter = nil) + "#{predicate_sql} (#{operand.to_sql(formatter)})" + end + end + + class Not < Unary + def predicate_sql; "NOT" end + end class CompoundPredicate < Binary def to_sql(formatter = nil) @@ -44,10 +54,8 @@ module Arel end end - class Not < Binary - def predicate_sql - operand2.not_predicate_sql - end + class Inequality < Equality + def predicate_sql; '!=' end end class GreaterThanOrEqualTo < Binary @@ -75,11 +83,11 @@ module Arel end class In < Binary - def to_sql + def to_sql(formatter = nil) if operand2.is_a?(Range) && operand2.exclude_end? GreaterThanOrEqualTo.new(operand1, operand2.begin).and( LessThan.new(operand1, operand2.end) - ).to_sql + ).to_sql(formatter) else super end |