Skip to content

Postgres syntax error for parameterized ALTER TYPE statement #906

Answered by porsager
amkhrjee asked this question in Q&A
Discussion options

You must be logged in to vote

You can't use protocol level parameters for queries like that. You need to use sql.unsafe, so something like this perhaps

await sql`
  ALTER TYPE tags ADD VALUE ${ sql.unsafe(`'${ tag.replace(/[^a-z]/g, '') }'`) }
`

If you're sure that tag is properly sanitized and not a way for sql injection to sneak in you can leave out the replace..

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@boromisp
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by amkhrjee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants