diff options
-rw-r--r-- | lib/arel/algebra/predicates.rb | 8 | ||||
-rw-r--r-- | lib/arel/engines/memory/predicates.rb | 2 | ||||
-rw-r--r-- | lib/arel/engines/sql/core_extensions/nil_class.rb | 4 | ||||
-rw-r--r-- | lib/arel/engines/sql/core_extensions/object.rb | 4 | ||||
-rw-r--r-- | lib/arel/engines/sql/predicates.rb | 2 | ||||
-rw-r--r-- | lib/arel/engines/sql/primitives.rb | 4 | ||||
-rw-r--r-- | spec/engines/sql/unit/predicates/noteq_spec.rb (renamed from spec/engines/sql/unit/predicates/not_spec.rb) | 6 |
7 files changed, 12 insertions, 18 deletions
diff --git a/lib/arel/algebra/predicates.rb b/lib/arel/algebra/predicates.rb index 5e17cdd101..d789c1d8a2 100644 --- a/lib/arel/algebra/predicates.rb +++ b/lib/arel/algebra/predicates.rb @@ -145,7 +145,13 @@ module Arel end end - class Inequality < Equality + class Inequality < Binary + def ==(other) + Equality === other and + ((operand1 == other.operand1 and operand2 == other.operand2) or + (operand1 == other.operand2 and operand2 == other.operand1)) + end + def complement Equality.new(operand1, operand2) end diff --git a/lib/arel/engines/memory/predicates.rb b/lib/arel/engines/memory/predicates.rb index 0e88810e7d..8b3e5843cc 100644 --- a/lib/arel/engines/memory/predicates.rb +++ b/lib/arel/engines/memory/predicates.rb @@ -52,7 +52,7 @@ module Arel def operator; :== end end - class Inequality < Equality + class Inequality < Binary def eval(row) operand1.eval(row) != operand2.eval(row) end diff --git a/lib/arel/engines/sql/core_extensions/nil_class.rb b/lib/arel/engines/sql/core_extensions/nil_class.rb index d4bb0e4c33..ab990d6211 100644 --- a/lib/arel/engines/sql/core_extensions/nil_class.rb +++ b/lib/arel/engines/sql/core_extensions/nil_class.rb @@ -9,10 +9,6 @@ module Arel 'IS NOT' end - def not_predicate_sql - 'IS NOT' - end - NilClass.send(:include, self) end end diff --git a/lib/arel/engines/sql/core_extensions/object.rb b/lib/arel/engines/sql/core_extensions/object.rb index 5415c84706..01c3c5479d 100644 --- a/lib/arel/engines/sql/core_extensions/object.rb +++ b/lib/arel/engines/sql/core_extensions/object.rb @@ -13,10 +13,6 @@ module Arel '!=' end - def not_predicate_sql - '!=' - end - Object.send(:include, self) end end diff --git a/lib/arel/engines/sql/predicates.rb b/lib/arel/engines/sql/predicates.rb index df8700a500..59b0ab0929 100644 --- a/lib/arel/engines/sql/predicates.rb +++ b/lib/arel/engines/sql/predicates.rb @@ -52,7 +52,7 @@ module Arel end end - class Inequality < Equality + class Inequality < Binary def predicate_sql operand2.inequality_predicate_sql end diff --git a/lib/arel/engines/sql/primitives.rb b/lib/arel/engines/sql/primitives.rb index 41769fa510..15a27b2256 100644 --- a/lib/arel/engines/sql/primitives.rb +++ b/lib/arel/engines/sql/primitives.rb @@ -42,10 +42,6 @@ module Arel value.inequality_predicate_sql end - def not_predicate_sql - value.not_predicate_sql - end - def to_sql(formatter = Sql::WhereCondition.new(relation)) formatter.value value end diff --git a/spec/engines/sql/unit/predicates/not_spec.rb b/spec/engines/sql/unit/predicates/noteq_spec.rb index b124d4c80b..ed24627323 100644 --- a/spec/engines/sql/unit/predicates/not_spec.rb +++ b/spec/engines/sql/unit/predicates/noteq_spec.rb @@ -13,7 +13,7 @@ module Arel describe '#to_sql' do describe 'when relating to a non-nil value' do it "manufactures a not predicate" do - sql = Not.new(@attribute1, @attribute2).to_sql + sql = Inequality.new(@attribute1, @attribute2).to_sql adapter_is :mysql do sql.should be_like(%Q{`users`.`id` != `photos`.`user_id`}) @@ -35,7 +35,7 @@ module Arel end it "manufactures an is null predicate" do - sql = Not.new(@attribute1, @nil).to_sql + sql = Inequality.new(@attribute1, @nil).to_sql adapter_is :mysql do sql.should be_like(%Q{`users`.`id` IS NOT NULL}) @@ -54,7 +54,7 @@ module Arel describe "when relating to a nil Value" do it "manufactures an IS NULL predicate" do value = nil.bind(@relation1) - sql = Not.new(@attribute1, value).to_sql + sql = Inequality.new(@attribute1, value).to_sql adapter_is :mysql do sql.should be_like(%Q{`users`.`id` IS NOT NULL}) |