Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse Default Var on ALTER TABLE #821

Open
Bloodiko opened this issue Mar 8, 2024 · 0 comments
Open

Unable to parse Default Var on ALTER TABLE #821

Bloodiko opened this issue Mar 8, 2024 · 0 comments

Comments

@Bloodiko
Copy link

Bloodiko commented Mar 8, 2024

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant