ALTER TYPE for enum syntax error for parameter substitution
Node: v13.11.0 Postgres Server: 9.5.21
Snippet:
Schema -
CREATE TYPE skilltype AS ENUM ('First', 'Second' );
Node -
let typename="Third";
pool.query('ALTER TYPE skilltype ADD VALUE $1;',[typename])
The expected behaviour would be for the typename to be parameterized appropriately, however, the parameterization fails for this query (with error: error: syntax error at or near "$1")
Duplicate of: #539, #1194, #1240, #1258, #1798, #150 🙈
PostgreSQL doesn't support dynamic enum values, the same way it doesn't support dynamic table names, etc.
If you want everything dynamic to be supported, you would need to use a library that implements its own query formatting, like pg-promise. This library however doesn't do its own query formatting, it only sends variables into the server, to be formatted there, hence the limitations.
https://www.npmjs.com/package/pg-format can format literals (with %L) into queries that don’t support parameterization.
Duplicate of #539