You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unlike in rails 6.0.6.1, ActiveRecord::Associations::CollectionProxy is behaving like a set in rails 6.1.7.3 where it no longer allows concating objects with the same object ID.
Steps to reproduce
classPerson < ApplicationRecordhas_many:friendsendclassFriend < ApplicationRecordbelongs_to:personendp=Person.new# instantiate new Person memory object not persisted to dbp.friends# => ActiveRecord::Associations::CollectionProxy []friend=Friend.new# instantiate new Friend memory object not persisted to dbp.friends << friendputsp.friends.size# => 1# add the same friend record againp.friends << friendputsp.friends.size# in rails 6.0.6.1 the result will be 2# in rails 6.1.7.3 the result is 1
Expected behavior
I expected that after adding the same friend object to the friends collection proxy twice, the size of the collection will increase by 2 as was the case in rails 6.0.6.1, especially as since this change was not documented in the changelog for Rails 6.1 😄
Actual behavior
In rails 6.1.7.3, the size remains at 1. Is ActiveRecord::Associations::CollectionProxy now behaving like a set and enforcing that its elements have unique object IDs?
System configuration
Rails version: 6.1.7.3
Ruby version: 2.7.6
The text was updated successfully, but these errors were encountered:
Hey @theobarango, thanks for opening an issue. Can you explain why you are expecting the previous behavior? (or are you just concerned about the change not being in the changelog?)
Hi @skipkayhil Hartley, thank you for getting back to me.
Yes my concern is that it was not included in the changelog, causing some of our specs that depended on this behaviour to fail following the upgrade to rails 6.1.7.3.
Looking at the PR I can see the motivation for the behaviour though. FWIW, i'm not asking for the behaviour to be reinstated, just pointing out that it was sort of a 'breaking change' that wasn't documented in the changelog.
Summary
Unlike in rails 6.0.6.1,
ActiveRecord::Associations::CollectionProxy
is behaving like a set in rails 6.1.7.3 where it no longer allows concating objects with the same object ID.Steps to reproduce
Expected behavior
I expected that after adding the same friend object to the friends collection proxy twice, the size of the collection will increase by 2 as was the case in rails 6.0.6.1, especially as since this change was not documented in the changelog for Rails 6.1 😄
Actual behavior
In rails 6.1.7.3, the size remains at 1. Is
ActiveRecord::Associations::CollectionProxy
now behaving like a set and enforcing that its elements have unique object IDs?System configuration
Rails version: 6.1.7.3
Ruby version: 2.7.6
The text was updated successfully, but these errors were encountered: