I am going to use responses from other people since I can't explain it better than they already did:
I've been doing ORM on Java since Hibernate was new, and it has always sucked. One of the selling points, which is now understood to be garbage, is that you can use different databases. But no-one uses different databases. Another selling point which is "you don't need to know SQL", is also garbage. Every non-trivial long-lived application will require tweaks to individual queries at the string level. The proper way to build a data layer is one query at a time, as a string, with string interpolation.
Couldn't agree with this more. The way I like to put it is "ORMs make the easy parts slightly easier, but they make the hard parts really hard". But I don't care that much about improving the easy parts, because they're already easy! Yet I can remember plenty of times when ORMs made my job a million times more difficult and all I was doing was fighting with the ORM itself (and usually at the worst time, e.g. when a query reached enough scale that it "fell over").
And even then, TypeORM would find a way to complain. For example, TypeORM was not consistent in using quotation marks (at least when I used it). So it could be that this query above still not works, because authorId is not quoted. But this should finally work (maybe):
- return "post.authorId IN " + subQuery
+ return 'post."authorId" IN ' + subQuery
And if it doesn't complain, it will create a really weird SQL query since it doesn't understand enough about your schema so it can't assume some things so it builds a query which is not exactly what you expect. But the query may return correct results first. Then you hit production and you get weird results.
So at the end, I had to know anyway how my SQL query should look like so it does exactly what I want, in 100% of the cases. And then I had to fight with TypeORM to generate this query. And then some more to get some acceptable performance.
At the end, I ditched it for knex and a few months later another team also ditched it and we never looked back.
There was also a hilarious issue in their Github where someone complained that he lost all rows in a table because a parameter he used to select rows was undefined and thus his .where("id", id) was silently dropped. The maintainer said this was not a bug but expected behavior. Wasn't able to find it between all these issues.
Same reason as interpreters running system or performance sensitive things, you know, like servers and device drivers and codecs and the like. It's a swiss army knife when a fixed blade is all you needed. The large majority of simpler types of table data that you need to access in a server are tens if not hundreds of times faster implemented as a key value store for each table.
Just look at what people report when they moved from Python to Go - typically a ten times increase in performance.
SQL isn't quite as complex as python but it is interpreted and the latency is increased a great deal compared to a native key value store on an log system like used in rocks, leveldb and such.
If you don't care about wasting, incredible amounts, of resources, then SQL is great because it's so widely supported and known. If you want to use as little as possible AND provide minimal latency, there is nothing faster than a rocksdb on an SSD storage, that's what Facebook uses.
authorId
is not quoted. But this should finally work (maybe):knex
and a few months later another team also ditched it and we never looked back..where("id", id)
was silently dropped. The maintainer said this was not a bug but expected behavior. Wasn't able to find it between all these issues.