stefankroes / ancestry

Organise ActiveRecord model into a tree structure
MIT License
3.72k stars 458 forks source link

fix increase_parent_counter_cache callback #618

Open kbrock opened 1 year ago

kbrock commented 1 year ago

Counter caches get corrupted.

It is possible that strategy: sql is the culprit here. There is also probably a problem around cache depth too.

The increase_parent_counter_cache callback is not consistent with the decrease_parent_counter_cache or the udpate


some ideas on making them consistent and fixing the problem

Not sure if update follows the same rules as destroy introduced in 63b42f53 But would like both trees to follow the same logic

There are reports of incorrect cache counts. So when insert and destroy have different guard clauses, it is suspect.

I admit that I am not totally familiar to the core use case so I will need to more into why this was introduced in #307 - trying to resolve #584 (and may be able to provide advice for #586 )

TODO:

kbrock commented 1 year ago

Feature (not fixing the bug):