Hacker News new | ask | show | jobs
by pgt 1359 days ago
Most engineers who say they want an ORM, really want query composition.
3 comments

Not really, they (I) wanted `insert(Item)` that just inserted the item into the table.

I don't really care about the query, just that it's inserted correctly, along with other operations that an ORM provide (get/delete/update,etc)

I think the data mapping part is pretty important: a programmatic way to map from SQL result sets to objects. That stuff is incredibly tedious (and error prone) when you do it manually.
Decomposing the result set is much simpler if the caller composed the query. Harder if you have to parse SQL to know what to expect back.
It depends. I've written a few half baked object mappers and never needed to parse SQL, since I've always used metadata from the result set (column names, data types, etc.)
What’s a good solution for that without a classic ORM?
Conditional text interpolation with named parameter bindings works quite well. We’ve basically abandoned the ORM for select queries at work as we find this approach more readable.
That sounds… flakey. Variable interpolated query strings are not even close to a substitute for an ORM?
Results are easily decomposed if you composed the query.