Arbitrary insert statement
I have a bit of an edge case where I want to build a query that is dynamic based on user input (it's part of an interactive tutorial). Is there a way to build an insert statement where the object name is an arbitrary string? Alternatively, is there some way to do this with sql framemgents, but still make the value a parameter? I'm imagining a
sql.parameter
function, but I don't see anything like that in the docs.3 Replies
Solution
Everything is a parameter by default when you use the
sql
tag.
id
in that example is sent as a parameter. It's not interpolated to the SQL.Alternatively you can use
Kysely<any>
to build any insert query
https://kyse.link/?p=s&i=DCFGKru80WvqqZ9KXBMdOh great! I don't know why I thought directly interpolating like that wouldn't work.