3 ms·
I stopped reading at the title "Problems arise". Example contains a piece of code that uses nested loops and each loop queries the db - producing many queries.
by fraktl 7y ago
I stopped reading at the title "Problems arise".
Example contains a piece of code that uses nested loops and each loop queries the db - producing many queries.
There's no problem with ActiveRecord. There's a big problem with programmers not learning relational databases.
Here's an excerpt from the post: "To get all ISBNs of all deceased Italian authors in the Active Record pattern"
Now look at this black magic: you create an SQL view with all the joins you need in order to cross-reference data and extract what you want, then you have your ORM use your view as if it were a table. Job done. Your code is now 1 liner and the database won't receive too many queries.
I know that the text references SQL views but this is what's said about them: "SQL has views too of course, but most ORMs don't have any support for them"
A view is, for all intents and purposes, a table to the ORM. There's no special support needed for it, if you use the view to read from it.
I'm sorry for being one of those guys who shit on someone's hard work, but the mister Cal Peterson missed the whole football field here.