Fix AttributeError with Sequence defaults in instant_defaults_listener#793
Merged
kurtmckee merged 1 commit intokvesteri:masterfrom Sep 30, 2025
wadinj:fix-sequence-defaults
Merged
Fix AttributeError with Sequence defaults in instant_defaults_listener#793kurtmckee merged 1 commit intokvesteri:masterfrom wadinj:fix-sequence-defaults
kurtmckee merged 1 commit intokvesteri:masterfrom
wadinj:fix-sequence-defaults
Conversation
The instant_defaults_listener was raising AttributeError when encountering columns with Sequence defaults, as it attempted to access the 'arg' attribute which doesn't exist on Sequence objects (only on ColumnDefault objects). This occurred when using force_instant_defaults() with models that have database sequences for primary keys or other columns, causing failures in scenarios like Celery task result storage. Resolution: - Add hasattr check for 'arg' attribute before accessing it - This generic approach handles Sequence and any other default types that don't have an 'arg' attribute - Add test case covering Sequence defaults to prevent regression
Collaborator
|
Thanks for this, and for adding a test case! |
Contributor
Author
|
Thanks for merging it! Thanks |
Contributor
Author
|
Any change to get a proper version with this? |
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.
The instant_defaults_listener was raising AttributeError when encountering columns with Sequence defaults, as it attempted to access the 'arg' attribute which doesn't exist on Sequence objects (only on ColumnDefault objects).
This occurred when using force_instant_defaults() with models that have database sequences for primary keys or other columns, causing failures in scenarios like Celery task result storage.
Resolution: