Don't crash when an altered column's old class is a custom Column subclass - #1429
Merged
dantownsend merged 1 commit intoSep 6, 2026
Merged
Conversation
…class
`SchemaDiffer.alter_columns` looks up `UniqueGlobalNames.COLUMN_<NAME>` for
both the new and the old column class, to spot an import that would conflict
with a name the generated migration already uses. The lookup for the new class
passes a `None` default; the one for the old class does not, so altering a
column whose previous class was a user-defined `Column` subclass raises
AttributeError: type object 'UniqueGlobalNames' has no attribute
'COLUMN_CUSTOMVARCHAR'
and `piccolo migrations new --auto` dies before writing anything.
`UniqueGlobalNames` only carries the built-in column classes, so a miss is the
expected outcome for any subclass a user defines — which is a supported thing
to do, and common for projects that wrap a column type to add a default or
narrow its type. Five of the six lookups in this module already pass `None`;
this makes the sixth behave the same way.
Closes piccolo-orm#1428
Member
|
Looks great, thanks! 👍 |
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.
SchemaDiffer.alter_columnslooks upUniqueGlobalNames.COLUMN_<NAME>for both the new and the old column class, to spot an import that would conflict with a name the generated migration already uses. The lookup for the new class passes aNonedefault; the one for the old class does not, so altering a column whose previous class was a user-definedColumnsubclass raisesand
piccolo migrations new --autodies before writing anything.UniqueGlobalNamesonly carries the built-in column classes, so a miss is the expected outcome for any subclass a user defines — which is a supported thing to do, and common for projects that wrap a column type to add a default or narrow its type. Five of the six lookups in this module already passNone; this makes the sixth behave the same way.Closes #1428 (#1428)