by svennek · 8y ago · 0 comments
There are no new abstractions (for example extra session/trransaction-like behaviour).
You can write good efficient SQL and not use an iteration-protocol.
ORMs tend to make slow and clumsy SQL. It might not matter if you only update one record, but if you need to fix something in 1 billion records, you are going to feel the pain..
If you need to learn real sql (and not clumsy beginner-sql), look at use-the-index-luke.com and modern-sql.com (both from the same, fantastic knowlegdeable guy) and read Joe Celkos "smarties" books...
If needed, a small library can help write CRUD style SQL. I have implemented them myself multiple times in an afternoon. Only tricky thing.. Handling of strings so that you have no SQL-injection.. (for that, serverside bind-parameters are a god-given).
They can certainly make for cleaner looking code, and are useful for people who don't really understand the database schema, but not worth the added complexity.
We actually wrote a custom query builder because none of the available ones (e.g. Doctrine) had the type safety that we desired. A direct parallel to what we used is the Java library JOOQ, in terms of its querybuilder API [0].
[0] https://www.jooq.org/doc/3.10/manual/sql-building/sql-statem...
Update: Fixed typos.
I've seen far too many cases where programmers get around their lack of SQL knowledge by writing a bunch of basic queries and then post-processing the results client side.