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

Added parameters if_exists and if_not_exists for index operations. #1260

Closed
wants to merge 2 commits into from

Conversation

ionsome
Copy link
Contributor

@ionsome ionsome commented Jun 14, 2023

Fixes: #151

Description

As mentioned in #151, IF EXISTS/IF NOT EXISTS syntax was implemented in SQLAlchemy 2.0. This request adds an ability to use them for index operations.

If the issue implies to implement all the possible cases with these directives, I could continue working on it 🙂

Checklist

This pull request is:

  • A documentation / typographical error fix
    • Good to go, no issue or tests are needed
  • A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

@ionsome
Copy link
Contributor Author

ionsome commented Jul 10, 2023

Hi @CaselIT
Have I missed anything?

@CaselIT
Copy link
Member

CaselIT commented Jul 10, 2023

sorry, I must have missed this.

I'll take a look soon

Copy link
Member

@CaselIT CaselIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work. Sorry for the delay.

A changelog is missing. see examples in https://github.com/sqlalchemy/alembic/tree/main/docs/build/unreleased . Also feel free to add "Pull request courtesy of <you>" if you like

kw = {}
if operation.if_not_exists is not None:
if not sqla_2:
raise NotImplementedError("SQLAlchemy 2.0+ required")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what's the usual behavior here when alembinc is trying to do something not supported by the installed sqlalchemy version.

@zzzeek do you remember if there is a rule for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found the rule but there is a similar case

if not sqla_compat.sqla_14_18:
raise NotImplementedError("SQLAlchemy 1.4.18+ required")

@zzzeek zzzeek requested a review from sqla-tester July 11, 2023 19:17
Copy link
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 8c087e4 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Collaborator

Failed to create a gerrit review, git squash against branch 'main' failed

@zzzeek
Copy link
Member

zzzeek commented Jul 11, 2023

the genreal idea here seems OK, let's run it through...

@CaselIT
Copy link
Member

CaselIT commented Jul 11, 2023

Failed to create a gerrit review, git squash against branch 'main' failed

is this something with a newer git version maybe?

@zzzeek
Copy link
Member

zzzeek commented Jul 11, 2023

OK Im really not sure why PRs aren't squshing now, can you please rebase this on main?

Copy link
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision 5ed62d1 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Collaborator

New Gerrit review created for change 5ed62d1: https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4782

@CaselIT
Copy link
Member

CaselIT commented Jul 11, 2023

OK Im really not sure why PRs aren't squshing now, can you please rebase this on main?

managed to rebase

@sqla-tester
Copy link
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4782 has been merged. Congratulations! :)

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

Successfully merging this pull request may close these issues.

IF EXISTS/IF NOT EXISTS directives
4 participants