This project is archived and is in readonly mode.
Accessing associations via x_ids no longer uses association conditions
-
Yuval Kordov
Forgot to add that this is using Ruby 1.9.2 and the mysql2 gem.
-
Yuval Kordov
Confirmed with 1.8.7.
-
2kan
- Tag changed from rails 3.0.3, associations, has_many to rails 3.0.3, associations, bug, has_many_through
Have the same bug in edge. It works correct for has_many but incorrect for has_many :through
-
Jon Leighton
- State changed from new to open
- Assigned user set to Aaron Patterson
- Importance changed from to Low
This problem was introduced by this optimisation: https://github.com/rails/rails/commit/373b053dc8b99dac1abc3879a17a2...
The optimisation could still work, but we'd need to be very cautious about when it's applied. For example, it could never be applied when there are
:conditionsor:orderoptions on the reflection, through_reflection, or source_reflection.My preference is to just revert the optimisation, I don't think it's worth muddying the code to tests for all these conditions to apply a small optimisation in a very specific case.
I've attached a patch with 1) a test which fails on master and 2) a commit which reverts the above, causing the test to pass again.
-
Repository
- State changed from open to resolved
(from [1619c2435b2b9c821b2b0dcab9624dbb6b23eaaa]) Revert "Optimize _ids for hm:t with belongs_to source". The optimisation has too many edge cases, such as when the reflection, source reflection, or through reflection has conditions, orders, etc. [#6153 Accessing associations via x_ids no longer uses association conditions state:resolved]
This reverts commit 373b053dc8b99dac1abc3879a17a2bf8c30302b5.
Conflicts:
activerecord/lib/active_record/associations.rbhttps://github.com/rails/rails/commit/1619c2435b2b9c821b2b0dcab9624...
