A DSL for writing SQL in a nice, composable way is a useful thing.
Some libraries, like SQLAlchemy, provide both levels, not insisting on using the object mapper.
A DSL for writing SQL in a nice, composable way is a useful thing.
Some libraries, like SQLAlchemy, provide both levels, not insisting on using the object mapper.
I actually would rather be writing Ruby on Rails, because it's _less magic_ than SQLalchemy.
It's pure magic.
I don't usually work on the "model" level, though; I work on "table" level.
But my very point was not to make it traverse object graphs at all. You can write nice SQL using it, with selects, joins, functions, etc. All these parts, SQL clauses, are composable, so you can factor out common parts.
Yes, I'm fine working with lists of tuples, not "model objects". Object graphs don't map all to well to the RDBMS model all too well. It's best done on case-by-case basis, if you care about performance at all.
[1](https://ponyorm.com/)
A DSL which manipulates queries and then produces syntactically valid SQL is tremendously valuable.
https://www.red-gate.com/simple-talk/sql/performance/control...
Also, views tend to pollute the namespace a bit: you want a set of descriptive names, per application, and possibly per application version. Schemata help here, though.
Templating can absolutely save time and boilerplate, but adding a DSL over a DSL in the form or ORM may well be the problem.