Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Root797783yI disagree.
There should be an easy way to update multiple records at once, such as `Order.where(“close_at < ?”, end_of_period).update_all(closed: true)`. Bulk processing! -
Bulk operations should be fast. And all options must be correct; i.e. covered by tests. The "easy"-part is subjective and depends on the language.
For example NHibernate (C#) is pretty straight forward: https://nhibernate.info/doc/...
You can then add integration tests and have an excellent compromise between performance (plain SQL under the hood), correctness and readability (operation written in the main programming language of the project).
Now we have two ways to modify data: the entity (good) and some random bulk-update (bad). We can unite both with the specification pattern, but that only increases complexity.
So, as long as you don't have SQL-like statements in your ORM operations, you should be fine. -
@Root The object part of ORM provides state guarantees not expressed in the database structure. Data which is accessed through an object and data which is accessed directly from the database should be isolated. Rails' way of allowing the user to bulk edit and destroy objects while silently skipping validation without even the guardrail of different classes for checked and unchecked operations is about as useful and safe as C's generics with void*
-
Root797783y@lbfalvy There are safe and unsafe versions of those: #delete calls validations and hooks, #destroy does not. There are also safe and unsafe ways to update records (though I’m less familiar with them; it’s #update_column, I believe?). Use the one you need at the time (and unsafe versions are typically only used for cleaning data.)
Related Rants
-
IHateForALiving12> TeamLeader1: I just discovered SQL is actually super fast! The low responsiveness I've experienced comes fro...
-
er1n15I was working on a very database heavy PHP app about six months ago. All database access was done directly, wi...
-
rhymiz27BuT wHy Do YoU uSe An ORM? YoU sHoUlD wRiTe RaW SQL fOr P e R f O r M a N c E
Whenever I see an ORM that supports creating and transforming objects in bulk, I can't help but think about the poor misdirected users who forced it to do that. It's an Object-Relational Mapper. It maps objects. The whole concept isn't designed for bulk operations, the point is that you add logic to each and every record and convert your operations to SQL so that you never have to keep a lot of them in memory.
rant
bulk
orm
misdesign