1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test
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
..
active_record/connection_adapters
assets
cases Correct through associations using scopes 2015-06-30 10:00:30 -07:00
fixtures Add pending test for the great-grandparent touching bug from #19324 2015-06-25 14:23:06 +02:00
migrations
models Add pending test for the great-grandparent touching bug from #19324 2015-06-25 14:23:06 +02:00
schema Add pending test for the great-grandparent touching bug from #19324 2015-06-25 14:23:06 +02:00
support
.gitignore
config.example.yml
config.rb