Skip to content

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