postgres
postgres copied to clipboard
Unable to parse Default Var on ALTER TABLE
I tried writing a transform script with this library for my table as I require it to have a new value.
So i used
sql`ALTER TABLE rewrite ALTER COLUMN token SET DEFAULT ${variable};`;
I tried this query in multiple different ways. I tried setting the Default directly while ADD COLUMN.
None worked.
The Result was always Postgres Error 42P18 -
Query became
ALTER TABLE rewrite ALTER COLUMN token SET DEFAULT $1;
Even though i actually did use the variable without quotes, which usually produce this error. Also, I did use the same variable in 2 other queries before, which did work as intended.
Not sure why ALTER TABLE does not like the DEFAULT setting here. ?
Why is $1 not transformed to the correct value for the given sql Query above ?