Re:Data denormalization is broken
by greenleafjacob on Friday September 30, 2016 @10:00PM
(#12616241)
I think SQLAlchemy is the only ORM I've used that has support for most/all of:
- Subqueries - HAVING clause - USE index hint - WHERE ... IN - SELECT DISTINCT - ON DUPLICATE KEY UPDATE - SELECT ... FOR UPDATE
The trouble comes when you're using an ORM that has some but not all of the features, then the abstraction falls apart and you need to go down to using SQL anyway.
Compared to the example that you gave, it's not. Where the latter becomes more interesting is when the identifiers are no longer string literals, but actual identifiers (i.e. once SQL records are mapped to some kind of tuple, structure or object type in the language). Then you get things such as static type verification, code completion, refactoring etc.
Note that this doesn't require a full fledged ORM. True object-relational mapping requires dealing with things such as object identity.
I myself have yet to embrace anything beyond what they call a database-abstraction layer, where instead of pg_query and mysql_query, you just have db_query, but you still have to write the SQL. So:
Is that so much worse than the more involved ORMs that let you write: