4 ms·
Most engineers who say they want an ORM, really want query composition.
by pgt 4y ago
Most engineers who say they want an ORM, really want query composition.
- yunohn 4y agoWhat’s a good solution for that without a classic ORM?
- nicoburns 4y agoConditional 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.
- yunohn 4y agoThat sounds… flakey. Variable interpolated query strings are not even close to a substitute for an ORM?
- pgt 4y agoResults are easily decomposed if you composed the query.
- icedchai 4y agoI 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.
- pgt 4y agoDecomposing 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.
- icedchai 4y agoIt 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.)
- Aperocky 4y agoNot 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)