4 ms·
There must be a way to upvote this comment more than once... :) I always get strange looks from my fellow programmers when I suggest that we just ditch the ORM
by typicalrunt 14y ago
There must be a way to upvote this comment more than once... :)
I always get strange looks from my fellow programmers when I suggest that we just ditch the ORM and use straight SQL. With some complex queries, like generating reports, I had a much easier time using iBATIS many years ago than hacking through ActiveRecord's oddities. AR is good for simple select/insert/update, but once you get into UNIONs and nested subqueries, you're fighting AR more than you should be.
- generalk 14y agoORMs -- in my case ruby's ActiveRecord -- solve nearly every use-case I have. Find a record by its primary key; get a record and all of the associated records from another table; update a record with a bunch of data? Why should I write any of that SQL? It's a waste of time. Is ActiveRecord running n+1 queries every time you call a method? You're doing it wrong. Ignorance of how an ORM works is not an indictment against ORMs. Is ActiveRecord generating really bad SQL for the fifty-table report you want to generate? Fine, ditch it. Run your own custom-written SQL, or a stored procedure, or whatever. Just because an ORM can't write all the SQL you'll ever need does not mean that they're useless.