3 ms·
You can map objects to db updates, and map query results to objects. Neither of those objects needs to have a mapping to actual relations, like how ORMs insist
by BlarfMcFlarf 2y ago
You can map objects to db updates, and map query results to objects. Neither of those objects needs to have a mapping to actual relations, like how ORMs insist on.
- threeseed 2y agoOnly for basic objects. The minute you add relationships your approach becomes unusable. There is a reason ORMs have persisted for over 30 years.
- wtetzner 2y agoNo it doesn't. Why would relationships matter? You handle the relationships in SQL queries, and just copy query results to structs.
- stickfigure 2y ago> copy query results to structs Congratulations, you've invented an ORM.
- ursuscamp 2y agoThat’s 1% of an ORM.
- stickfigure 2y agoIt's at least 30% of most ORMs. And if your homebrew ORM actually gets wide use, it'll grow from there. Source: Wrote an ORM that other people actually use. Still adding features, twelve years later.
- threeseed 2y agoMajority of ORMs really are nothing more than this. But then it's nice to have something that generates optimised, database-specific SQL, can handle date/number conversion, supports many-many relationships, converting BLOB to binary streams etc.
- wtetzner 2y agoThis is clearly not what anyone means when they say they don't want an ORM. An ORM library maps an entire relational database to a graph of objects, with the intention of abstracting away the relational database. Copying query results to structs doesn't actually do any of that. https://en.m.wikipedia.org/wiki/Object%E2%80%93relational_mapping https://en.m.wikipedia.org/wiki/Object%E2%80%93relational_ma...
- deleted 2y ago[deleted]
- dragonwriter 2y agoQuery results are actual, if transitory, relations. And db updates are either relations or tuples (and a tuple is a relation with cardinality of 1, so...)
- wtetzner 2y agoYou can be pedantic if you like, but this is obviously not what anyone means by "ORM".
- dragonwriter 2y agoIts literally the exact things that ORMs map between: query results -> objects and object changes -> database updates.
- wtetzner 2y agoNo, ORMs abstract away the relational database and present it as if it were some kind of object database. Needing to map query results to structs is just incidental, and is completely missing the point of an ORM. If copying query results to a list of structs is enough to qualify as an ORM, then the term is so generic as to be entirely useless.