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/cases/associations
Michael Fowler 9aa59f9d4a Avoid extraneous preloading when loading across has_one associations
The Preloader relies on other objects to bind the retrieved records to their
parents. When executed across a hash, it assumes that the results of
`preloaded_records` is the appropriate set of records to pass in to the next
layer.

Filtering based on the reflection properties in `preloaded_records` allows us to
avoid excessive preloading in the instance where we are loading across a
`has_one` association distinguished by an order (e.g. "last comment" or
similar), by dropping these records before they are returned to the
Preloader. In this situation, we avoid potentially very long key lists in
generated queries and the consequential AR object instantiations.

This is mostly relevant if the underlying linked set has relatively many
records, because this is effectively a multiplier on the number of records
returned on the far side of the preload. Unfortunately, avoiding the
over-retrieval of the `has_one` association seems to require substantial changes
to the preloader design, and probably adaptor-specific logic -- it is a
top-by-group problem.
2020-01-08 08:14:04 +13:00
..
belongs_to_associations_test.rb Make belongs_to_required_by_default a class attribute: 2019-12-17 19:17:58 +01:00
bidirectional_destroy_dependencies_test.rb
callbacks_test.rb Fix collection callbacks not terminating when abort is thrown 2019-11-06 18:19:33 +09:00
cascaded_eager_loading_test.rb Avoid extraneous preloading when loading across has_one associations 2020-01-08 08:14:04 +13:00
eager_load_includes_full_sti_class_test.rb Fix CI failure due to remaining tagging records 2019-03-26 12:59:16 +09:00
eager_load_nested_include_test.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
eager_singularization_test.rb
eager_test.rb Merge pull request #37747 from bradleyprice/check-association-loaded-across-collection-on-preload 2019-11-20 08:53:50 +09:00
extension_test.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
has_and_belongs_to_many_associations_test.rb Fix join middle table alias when using HABTM 2019-07-26 23:12:44 +09:00
has_many_associations_test.rb Fix random CI failure due to non-deterministic sorting order 2019-12-03 09:43:27 +09:00
has_many_through_associations_test.rb Refactor association.scoping not to rely on klass.all 2019-10-22 00:06:31 +09:00
has_one_associations_test.rb :polymorphic, :as, and :foreign_type are valid for polymorphic association 2019-11-10 10:54:58 +09:00
has_one_through_associations_test.rb More exercise singular association query 2018-11-28 03:34:20 +09:00
inner_join_association_test.rb Maintain eager loading joining order as before 2019-09-18 17:42:15 +09:00
inverse_associations_test.rb Check that entire collection has been loaded before short circuiting 2019-11-19 15:32:36 -06:00
join_model_test.rb
left_outer_join_association_test.rb Fix merging left_joins to maintain its own join_type context 2019-04-27 21:43:57 +09:00
nested_through_associations_test.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
required_test.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00