Skip to content

Conversation

wadinj
Copy link
Contributor

@wadinj wadinj commented Sep 30, 2025

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
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
Copy link
Contributor Author

wadinj commented Oct 1, 2025

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

Thanks

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