Fix duplicate CHECK constraints for Boolean/Enum in batch mode#1793
Open
khanjan2708 wants to merge 3 commits intosqlalchemy:mainfrom
Open
Fix duplicate CHECK constraints for Boolean/Enum in batch mode#1793khanjan2708 wants to merge 3 commits intosqlalchemy:mainfrom
khanjan2708 wants to merge 3 commits intosqlalchemy:mainfrom
Conversation
- Suppress automatic type-level events during batch add/alter column - Inherit naming convention in temporary batch metadata - Automatically detect naming convention from migration context Fixes: sqlalchemy#1768
zzzeek
reviewed
Feb 20, 2026
Member
zzzeek
left a comment
There was a problem hiding this comment.
thanks for this, please let me know if you want me to finish it up w/ changelog and compat function
alembic/operations/batch.py
Outdated
| existing.type = type_ | ||
|
|
||
| if isinstance(existing.type, SchemaEventTarget): | ||
| existing.type._create_events = ( # type:ignore[attr-defined] |
Member
There was a problem hiding this comment.
this seems like a good place for a sqla_compat function. there's not a fixed way to remove the events from a SchemaType and it might change.
sqla-tester
reviewed
Feb 20, 2026
Collaborator
sqla-tester
left a comment
There was a problem hiding this comment.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision f34f0f1 of this pull request into gerrit so we can run tests and reviews and stuff
Collaborator
|
New Gerrit review created for change f34f0f1: https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6602 |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes: #1768
This PR prevents the generation of duplicate
CHECKconstraints when adding or alteringBoolean/Enumcolumns in batch mode while using a naming convention.The Fix :
CHECKconstraint generation during batch migrations to avoid collisions with Alembic's explicit operations.batch_alter_tableto automatically pull the naming convention from the migration context.Checklist
This pull request is:
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>in the commit messageinclude a complete example of how the feature would look.
Fixes: #<issue number>in the commit messageHave a nice day!