Skip to content

Fix issue 567 conditional save default #1279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ljluestc
Copy link

Fixes #567, where conditional saves fail for existing items when a new field with a default value is added to a model. The issue occurs because existing items have null or missing values, causing a mismatch during conditional saves.

Changes

  • Modified Model.save to apply default values for null attributes before saving.
  • Added update_items_with_default_values utility to migrate existing items.
  • Added tests in tests/test_conditional_save.py to verify the fix.
  • Updated documentation in docs/guide.rst and CHANGELOG.md.

Testing

  • Added async tests using pytest-asyncio to cover both existing and new items.
  • Verified with local DynamoDB table and AWS credentials.
  • Ran black and flake8 to ensure code style compliance.

Closes #567.

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.

Conditional save fails for new field with default value
1 participant