-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat(postgres): support for ADD COLUMN IF NOT EXISTS
and DROP COLUMN IF EXISTS
#15119
feat(postgres): support for ADD COLUMN IF NOT EXISTS
and DROP COLUMN IF EXISTS
#15119
Conversation
@ephys I have few questions on this as you mentioned that dialects that don't support this should throw, I do think there are some workarounds for few of them should I try and implement them if possible. Like for ones that don't support it as you mentioned they can first query it and then try and add it if not exists. Second question I have is passing that option in the Also another question is, as you said should all the dialects that don't support this feature should throw right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to tackle that in this PR as well |
Maybe you can rename this PR to includes |
IF NOT EXISTS
support for PostgresIF NOT EXISTS
and DROP IF NOT EXISTS
IF NOT EXISTS
and DROP IF NOT EXISTS
IF NOT EXISTS
and DROP IF EXISTS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work :)
Yes feel free to add DROP COLUMN
it in this PR if you prefer, splitting it is fine too
Could you add a unit test in unit/query-generator/add-column-query.test.ts
?
All dialects should be tested, but the ones that don't support the option should throw (like in list-databases-query.test.ts
)
I don't think you need an integration test for this option
I do think there are some workarounds for few of them should I try and implement them if possible
I think we can look into that if there is interest but I'd propose to keep it for a follow-up PR
IF NOT EXISTS
and DROP IF EXISTS
CREATE COLUMN IF NOT EXISTS
and DROP COLUMN IF EXISTS
CREATE COLUMN IF NOT EXISTS
and DROP COLUMN IF EXISTS
ADD COLUMN IF NOT EXISTS
and DROP COLUMN IF EXISTS
Better PR name :) |
Gotta be super explicit for the changelog :p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments about your tests, haven't looked into the rest yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this is not a postgres exclusive feature
@ephys I'll let you look at the type definitions for {add,remove}ColumnQuery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I'm OK with adding support for other dialects in follow-up PRs. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's add support for additional dialects in future PRs and merge this one now. Would be nice if you could still work on those @frostzt :)
Happy to see this is landed! |
@WikiRik thanks I'll start working on those! |
Pull Request Checklist
Description Of Change
Its a feature request opened by #14928
Postgres supports
IF NOT EXISTS
clause on adding columns. Adds support for Postgres dialect!Todos
IF NOT EXISTS
both Unit and Integration