diff --git a/lib/active_relation/predicates.rb b/lib/active_relation/predicates.rb index e17a9f82fe..dc4610b052 100644 --- a/lib/active_relation/predicates.rb +++ b/lib/active_relation/predicates.rb @@ -25,7 +25,7 @@ module ActiveRelation end def to_sql(formatter = nil) - "#{operand2.format(operand1)} #{predicate_sql} #{operand1.format(operand2)}" + "#{operand1.to_sql} #{predicate_sql} #{operand1.format(operand2)}" end def descend diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb index d78e940ffc..ddf5ef5e07 100644 --- a/lib/active_relation/primitives/attribute.rb +++ b/lib/active_relation/primitives/attribute.rb @@ -63,31 +63,31 @@ module ActiveRelation module Predications def eq(other) - Equality.new(self, other.bind(relation)) + Equality.new(self, other) end def lt(other) - LessThan.new(self, other.bind(relation)) + LessThan.new(self, other) end def lteq(other) - LessThanOrEqualTo.new(self, other.bind(relation)) + LessThanOrEqualTo.new(self, other) end def gt(other) - GreaterThan.new(self, other.bind(relation)) + GreaterThan.new(self, other) end def gteq(other) - GreaterThanOrEqualTo.new(self, other.bind(relation)) + GreaterThanOrEqualTo.new(self, other) end def matches(regexp) - Match.new(self, regexp.bind(relation)) + Match.new(self, regexp) end def in(array) - In.new(self, array.bind(relation)) + In.new(self, array) end end include Predications diff --git a/spec/active_relation/unit/predicates/binary_spec.rb b/spec/active_relation/unit/predicates/binary_spec.rb index 04f8d4f305..5dd5e5599a 100644 --- a/spec/active_relation/unit/predicates/binary_spec.rb +++ b/spec/active_relation/unit/predicates/binary_spec.rb @@ -24,7 +24,7 @@ module ActiveRelation describe 'when relating an attribute and a value' do before do - @value = "1-asdf".bind(@relation) + @value = "1-asdf" end describe 'when relating to an integer attribute' do @@ -43,19 +43,6 @@ module ActiveRelation end end end - - describe 'when relating two values' do - before do - @value = "1-asdf".bind(@relation) - @another_value = 2.bind(@relation) - end - - it 'formats values appropos of their type' do - ConcreteBinary.new(string = @value, integer = @another_value).to_sql.should be_like(" - '1-asdf' <=> 2 - ") - end - end end describe '==' do diff --git a/spec/active_relation/unit/predicates/equality_spec.rb b/spec/active_relation/unit/predicates/equality_spec.rb index 613236ad04..5415b35925 100644 --- a/spec/active_relation/unit/predicates/equality_spec.rb +++ b/spec/active_relation/unit/predicates/equality_spec.rb @@ -35,7 +35,7 @@ module ActiveRelation describe 'when relation to a nil value' do before do - @nil = nil.bind(@relation1) + @nil = nil end it "manufactures an is null predicate" do diff --git a/spec/active_relation/unit/primitives/attribute_spec.rb b/spec/active_relation/unit/primitives/attribute_spec.rb index 0f6e5e289d..fbbcbaef37 100644 --- a/spec/active_relation/unit/primitives/attribute_spec.rb +++ b/spec/active_relation/unit/primitives/attribute_spec.rb @@ -21,7 +21,7 @@ module ActiveRelation end it "returns self if the substituting to the same relation" do - @attribute.bind(@relation).should == @attribute + @attribute.should == @attribute end end @@ -97,43 +97,43 @@ module ActiveRelation describe '#eq' do it "manufactures an equality predicate" do - @attribute.eq('name').should == Equality.new(@attribute, 'name'.bind(@relation)) + @attribute.eq('name').should == Equality.new(@attribute, 'name') end end describe '#lt' do it "manufactures a less-than predicate" do - @attribute.lt(10).should == LessThan.new(@attribute, 10.bind(@relation)) + @attribute.lt(10).should == LessThan.new(@attribute, 10) end end describe '#lteq' do it "manufactures a less-than or equal-to predicate" do - @attribute.lteq(10).should == LessThanOrEqualTo.new(@attribute, 10.bind(@relation)) + @attribute.lteq(10).should == LessThanOrEqualTo.new(@attribute, 10) end end describe '#gt' do it "manufactures a greater-than predicate" do - @attribute.gt(10).should == GreaterThan.new(@attribute, 10.bind(@relation)) + @attribute.gt(10).should == GreaterThan.new(@attribute, 10) end end describe '#gteq' do it "manufactures a greater-than or equal-to predicate" do - @attribute.gteq(10).should == GreaterThanOrEqualTo.new(@attribute, 10.bind(@relation)) + @attribute.gteq(10).should == GreaterThanOrEqualTo.new(@attribute, 10) end end describe '#matches' do it "manufactures a match predicate" do - @attribute.matches(/.*/).should == Match.new(@attribute, /.*/.bind(@relation)) + @attribute.matches(/.*/).should == Match.new(@attribute, /.*/) end end describe '#in' do it "manufactures an in predicate" do - @attribute.in(1..30).should == In.new(@attribute, (1..30).bind(@relation)) + @attribute.in(1..30).should == In.new(@attribute, (1..30)) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 01a703a7d4..4b61ae8ca8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,7 +19,7 @@ ActiveRecord::Base.establish_connection 'test' class Hash def shift - returning to_a.sort { |(key1, value1), (key2, value2)| key1.hash <=> key2.hash }.shift do |key, value| + returning to_a.sort { |(key1, value1), (key2, value2)| key1.hash <=> key2.hash }.shift do |key, _| delete(key) end end