bitemyapp / esqueleto

New home of Esqueleto, please file issues so we can get things caught up!
BSD 3-Clause "New" or "Revised" License
376 stars 108 forks source link

Support using `insertSelect` with an entire `Entity` #367

Open isomorpheme opened 1 year ago

isomorpheme commented 1 year ago

Sometimes I want to insert entire entities into a table, from a SELECT query, including the primary key.[^1] As far as I can tell, this isn't possible with the current insertSelect & Insertion API - the PersistEntity constraint and the types of (<#) and (<&>) get in the way.

The easiest way to support this is probably with an extra insertSelectEntity, to parallel insertEntityMany from Persistent. I haven't yet tried to come up with a safe type for such a function.

[^1]: My use case right now actually involves a REPLACE, as in #86, but it's otherwise the same idea.