Skip to content
  • aaron's avatar
    432698ef
    Fix `SELECT COUNT` queries when rendering ActiveRecord collections (#40870) · 432698ef
    aaron authored
    * 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]
    432698ef
    Fix `SELECT COUNT` queries when rendering ActiveRecord collections (#40870)
    aaron authored
    * 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]
Loading