Skip to content

Fix AttributeError with Sequence defaults in instant_defaults_listener#793

Merged
kurtmckee merged 1 commit into
kvesteri:masterfrom
wadinj:fix-sequence-defaults
Sep 30, 2025
Merged

Fix AttributeError with Sequence defaults in instant_defaults_listener#793
kurtmckee merged 1 commit into
kvesteri:masterfrom
wadinj:fix-sequence-defaults

Conversation

@wadinj

@wadinj wadinj commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

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

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
@kurtmckee

Copy link
Copy Markdown
Collaborator

Thanks for this, and for adding a test case!

@kurtmckee kurtmckee merged commit 4a7d764 into kvesteri:master Sep 30, 2025
12 checks passed
@wadinj

wadinj commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for merging it!
Is this possible to get a minor version included this?

Thanks

@wadinj

wadinj commented Nov 18, 2025

Copy link
Copy Markdown
Contributor Author

Any change to get a proper version with this?

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.

2 participants