Unable to parse Default Var on ALTER TABLE
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
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 ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files or tests. Start by reproducing the shown ALTER TABLE query and PostgreSQL error 42P18, then trace how the JavaScript template query becomes ALTER COLUMN ... SET DEFAULT $1; done means identifying whether this form should be supported and establishing the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100