1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/active_record/associations
Sean Griffin bc6ac8609c Correct through associations using scopes
The changes introduced to through associations in c80487eb were quite
interesting. Changing `relation.merge!(scope)` to `relation =
relation.merge(scope)` should in theory never cause any changes in
behavior. The subtle breakage led to a surprising conclusion.

The old code wasn't doing anything! Since `merge!` calls
`instance_exec` when given a proc, and most scopes will look something
like `has_many :foos, -> { where(foo: :bar) }`, if we're not capturing
the return value, it's a no-op. However, removing the `merge` causes
`unscope` to break.

While we're merging in the rest of the chain elsewhere, we were never
merging in `unscope` values, causing a breakage on associations where a
default scope was being unscoped in an association scope (yuk!). This is
subtly related to #20722, since it appears we were previously relying on
this mutability.

Fixes #20721.
Fixes #20727.
2015-06-30 10:00:30 -07:00
..
builder Rename association option :class to :anonymous_class 2015-04-21 08:48:22 -04:00
join_dependency Remove Relation#bind_params 2015-01-27 16:10:03 -07:00
preloader Remove most type related predicates from Column 2015-01-30 11:42:54 -07:00
alias_tracker.rb Move #type_caster to alias tracker initialize 2015-01-02 17:15:31 -05:00
association.rb thrown ActiveRecord::AssociationTypeMismatch when assigning a wrong value for a namespaced association 2015-06-22 12:38:54 -03:00
association_scope.rb Correct through associations using scopes 2015-06-30 10:00:30 -07:00
belongs_to_association.rb raise ActiveModel::MissingAttributeError when trying to access a relationship without the foreign key attribute 2015-06-16 16:12:52 -03:00
belongs_to_polymorphic_association.rb
collection_association.rb Fix a regression introduced by removing unnecessary db call when replacing 2015-04-04 12:48:36 +00:00
collection_proxy.rb [ci skip] fix the collection.clear guide 2015-06-02 22:16:10 -05:00
foreign_association.rb Share foreign_key_present? implementation in _has_ associations 2014-12-31 00:19:09 +03:00
has_many_association.rb Correct errors in counter cache updating 2015-02-03 13:28:07 -07:00
has_many_through_association.rb Autosave existing records on HMT associations when the parent is new 2015-04-18 10:47:04 -04:00
has_one_association.rb Deprecate false as the way to halt AR callbacks 2015-01-02 15:31:56 -08:00
has_one_through_association.rb
join_dependency.rb Merge pull request #16989 from Empact/reload-cache-clear 2015-02-20 17:45:10 -02:00
preloader.rb docs, nodoc NullPreloader and AlreadyLoaded. 2015-06-29 14:47:11 +02:00
singular_association.rb Fix undefined method uncached for polymorphic belongs_to #20426 2015-06-13 18:36:06 -04:00
through_association.rb Correct through associations using scopes 2015-06-30 10:00:30 -07:00