Take Prisma. Very useful to autocomplete tables and column names. Catches mistakes early.<p>But my workflow generally goes like this: Write raw SQL in TablePlus to see what data comes back, then translate this raw SQL query into a Prisma query.<p>Why not have a converter convert raw sql queries into Prisma queries?<p>Another use case is as soon as any of my SQL queries get complicated (20+ lines), raw SQL becomes much easier to write. It'd be nice to automatically translate this to a Prisma query.
There's always an impedence mismatch for anything but the simplest data structures. It's SQL 101. Try it a few times and you'll see what a pain in the ass it is - there's always tradeoffs. Remember, the objects need to write data as well as read it. If your SQL Query is especially complex, reversing the joins to update individual tables can be a nightmare.<p><a href="https://en.m.wikipedia.org/wiki/Object%E2%80%93relational_impedance_mismatch" rel="nofollow">https://en.m.wikipedia.org/wiki/Object%E2%80%93relational_im...</a>
Because ORMs exist to <i>avoid</i> writing the SQL. The workflow is ORM first, then if it’s not good enough, optimise, then if that’s not enough, drop down to raw SQL. If your just writing the SQL then you kinda don’t need it. Most ORMs have a mechanism to pass on a raw SQL query and serialise the results into the appropriate objects/structs.