haskellari / postgresql-simple

Mid-level client library for accessing PostgreSQL from Haskell
Other
88 stars 46 forks source link

Support inserting into variable number of subset of fields #125

Open robinp opened 1 year ago

robinp commented 1 year ago

Hello,

It would be nice to support something like

execute conn "INSERT INTO tbl (?) VALUES (?)" (Multiple (ColNames [Identifier "a", ...]), Multiple (Values ...))

(Edit: added the Multiple constructor as something provisional)

Currently I need to perform some manual text concatenation of the Query string with repeat 5 "?" and the like, which is not very elegant.

Just an idea, not high-priority though. Alternate ideas welcome too.

phadej commented 1 year ago

I mentioned that previously, I'm not a fan extending what postgresql-simple beyond what PQexecParams does (though it's not planned that postgresql-simple would start using it)