1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib/action_view/renderer
aaron 432698ef2b
Fix SELECT COUNT queries when rendering ActiveRecord collections (#40870)
* Fix `SELECT COUNT` queries when rendering ActiveRecord collections

Fixes #40837

When rendering collections, calling `size` when the collection is an
ActiveRecord relation causes unwanted `SELECT COUNT(*)` queries. This
change ensures the collection is an array before getting the size, and
also loads the relation for any further array inspections.

* Test queries when rendering relation collections

* Add `length` support to partial collection iterator

Allows getting the size of a relation without duplicating records, but
still loads the relation. The length method existence needs to be
checked because you can pass in an `Enumerator`, which does not respond
to `length`.

* Ensure unsubscribed from notifications after tests

[Rafael Mendonça França + aar0nr]
2020-12-18 15:58:11 -05:00
..
partial_renderer Ensure cache fragment digests include all templates 2020-05-26 15:52:05 -04:00
abstract_renderer.rb Revert "Raise when calling render with invalid options" 2020-10-29 13:49:30 -07:00
collection_renderer.rb Fix SELECT COUNT queries when rendering ActiveRecord collections (#40870) 2020-12-18 15:58:11 -05:00
object_renderer.rb Fix issue in ActionText 2020-02-27 16:54:50 -08:00
partial_renderer.rb Revert "Raise when calling render with invalid options" 2020-10-29 13:49:30 -07:00
renderer.rb Include layout when rendering objects from controllers 2020-10-14 11:49:45 -06:00
streaming_template_renderer.rb Call AS::Notifications.instrument directly in AV 2020-03-31 21:51:44 -07:00
template_renderer.rb Remove deprecated support to passing absolute paths to render template: 2020-10-30 00:25:15 +00:00