logoalt Hacker News

karmakaze05/03/20251 replyview on HN

By upsert_all not invoking model callbacks, it's admitting that the ActiveRecord approach doesn't scale.

"It can be as simple as extracting your callback..." Isn't this the kind of repetitive thing a framework should be doing on your behalf?

To be fair, ActiveRecord isn't a fault Rails invented. Apparently it's from one of Martin Fowler's many writings where each model instance manages its own storage. Even Fowler seems to say that the DataMapper approach is better to separate concerns in complex scenarios.


Replies

makeitdouble05/04/2025

TBF no framework will do everything perfectly, and having clean escape hatches is pretty good in itself.

Even outside of batch processing, there will usually be a few queries that absolutely benefit from being rewritten in a lower layer of the ORM or even plain SQL. It's just a fact of life.