Skip to content
  • Sean Griffin's avatar
    232115a9
    Improve consistency of counter caches updating in memory · 232115a9
    Sean Griffin authored
    When we made sure that the counter gets updated in memory, we only did
    it on the has many side. The has many side only does the update if the
    belongs to cannot. The belongs to side was updated to update the counter
    cache (if it is able). This means that we need to check if the
    belongs_to is able to update in memory on the has_many side.
    
    We also found an inconsistency where the reflection names were used to
    grab the association which should update the counter cache. Since
    reflection names are now strings, this means it was using a different
    instance than the one which would have the inverse instance set.
    
    Fixes #18689
    
    [Sean Griffin & anthonynavarre]
    
    Conflicts:
    	activerecord/test/cases/counter_cache_test.rb
    232115a9
    Improve consistency of counter caches updating in memory
    Sean Griffin authored
    When we made sure that the counter gets updated in memory, we only did
    it on the has many side. The has many side only does the update if the
    belongs to cannot. The belongs to side was updated to update the counter
    cache (if it is able). This means that we need to check if the
    belongs_to is able to update in memory on the has_many side.
    
    We also found an inconsistency where the reflection names were used to
    grab the association which should update the counter cache. Since
    reflection names are now strings, this means it was using a different
    instance than the one which would have the inverse instance set.
    
    Fixes #18689
    
    [Sean Griffin & anthonynavarre]
    
    Conflicts:
    	activerecord/test/cases/counter_cache_test.rb
Loading