Fix duplicate CHECK constraints for Boolean/Enum in batch mode#1793
Fix duplicate CHECK constraints for Boolean/Enum in batch mode#1793khanjan2708 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
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] |
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
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
|
New Gerrit review created for change f34f0f1: https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6602 |
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 51c3037 of this pull request into gerrit so we can run tests and reviews and stuff
|
Patchset 51c3037 added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/6602 |
zzzeek
left a comment
There was a problem hiding this comment.
need to remove unrelated typing changes, if there are issues there, those should be fixed separately
| reflect_args: Tuple[Any, ...] = (), | ||
| reflect_kwargs: Mapping[str, Any] = util.immutabledict(), | ||
| naming_convention: Optional[Dict[str, str]] = None, | ||
| naming_convention: Optional[Mapping[Any, Any]] = None, |
There was a problem hiding this comment.
these typing changes should not be part of this. if this was the only reason for fails then we'd need to look at our CI setup
| import struct | ||
|
|
||
| ioctl = fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack("HHHH", 0, 0, 0, 0)) | ||
| ioctl = fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack("HHHH", 0, 0, 0, 0)) # type: ignore[attr-defined] |
There was a problem hiding this comment.
this seems totally random, would remove this
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!