Chris Mear
2006-Jul-05 14:07 UTC
New records now considered equal if their attributes are equal (ActiveRecord, r4552)
Hello list, In light of this recent change: --- lib/active_record/base.rb (revision 4551) +++ lib/active_record/base.rb (revision 4552) @@ -1646,8 +1646,9 @@ def ==(comparison_object) comparison_object.equal?(self) || (comparison_object.instance_of?(self.class) && - comparison_object.id == id && - !comparison_object.new_record?) + ((!comparison_object.new_record? && comparison_object.id == id) || + (comparison_object.new_record? && comparison_object.attributes == attributes)) + ) end this test needs amending: test/base_test.rb (revision 4553): def test_equality_of_new_records assert_not_equal Topic.new, Topic.new end because those two new Topics are now considered equal. Just a heads-up to anyone else who, like me, missed this change, and was a bit confused by the failing test... Cheers, Chris
Michael Koziarski
2006-Jul-05 14:16 UTC
Re: New records now considered equal if their attributes are equal (ActiveRecord, r4552)
On 7/5/06, Chris Mear <chris@feedmechocolate.com> wrote:> Hello list, > > In light of this recent change:That''s a strange change to embed in an oracle fix? Was it intentional david? Michael? http://dev.rubyonrails.org/changeset/4552 I personally don''t like the change at all, the previous behaviour of falling back to object_id was definitely more in keeping with expectations.> Just a heads-up to anyone else who, like me, missed this change, and > was a bit confused by the failing test... > > Cheers, > Chris > > _______________________________________________ > Rails-core mailing list > Rails-core@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-core >-- Cheers Koz
Rick Olson
2006-Jul-05 14:24 UTC
Re: New records now considered equal if their attributes are equal (ActiveRecord, r4552)
> > In light of this recent change: > > That''s a strange change to embed in an oracle fix? Was it > intentional david? Michael?I rolled it back. The ticket for the change was denied prior to the commit. -- Rick Olson http://techno-weenie.net
Michael A. Schoen
2006-Jul-05 17:06 UTC
Re: New records now considered equal if their attributes are equal (ActiveRecord, r4552)
Michael Koziarski wrote:> That''s a strange change to embed in an oracle fix? Was it > intentional david? Michael? > > http://dev.rubyonrails.org/changeset/4552Agreed, that wasn''t in my patch. I presume another patch from somebody else got applied by mistake?
David Heinemeier Hansson
2006-Jul-06 15:07 UTC
Re: Re: New records now considered equal if their attributes are equal (ActiveRecord, r4552)
> Agreed, that wasn''t in my patch. I presume another patch from somebody > else got applied by mistake?Yup, applied by mistake. Rick rolled it back. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework