Skip to content
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

DynamoDB Enhanced Client Versioned Record start at 0 #5565

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akiesler
Copy link
Contributor

@akiesler akiesler commented Sep 5, 2024

This allows for clients using the DynamoDB Versioned Record Extension to start their versions at 0 instead of null thus preventing clients from being required to use the Integer type and instead allowing them to use the int primitive.
This change also makes the extension more flexible by allowing clients to set the starting value and incrementing value if they have a use-case to do so.

Motivation and Context

Most developers would expect a version to start at 0 and increment from their instead of having to have a special case where the value must be initialized to null (see #3894).

Modifications

Updates the internal logic of VersionedRecordExtension to accept either a null value or a numeric value equal to the starting value.

Testing

Added a unit tests for explicitly setting the version to 0 during initial creation.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@akiesler akiesler requested a review from a team as a code owner September 5, 2024 23:52
@akiesler akiesler force-pushed the dynamodb-enhanced-versioned-record-start-at-0 branch from 770be52 to cc9f67a Compare September 5, 2024 23:53
Andy Kiesler added 2 commits September 23, 2024 09:46
The intent is to breakdown the internal logic into smaller methods to make
the overall flow more obvious to other developers.
The prior behavior required that a version be initialized with a null value,
this required mapper clients to use Integer instead of the int primitive.
This change allows clients to explicitly initialize the version to a value
which makes it simpler for clients to use primitive values and potentially
avoid null pointer exceptions and checks.

The default starting value of 0 and increment value of 1 are intended to
provide sane defaults that are identical to the existing behavior while
enabling clients to have more fine-graned control over how the versioning
is managed for their specific use-cases.

The current implementation configures the values at the extension level only
but the implementation can be expanded to gather the value from the model
annotation to customize the values on a per table basis.
@akiesler akiesler force-pushed the dynamodb-enhanced-versioned-record-start-at-0 branch from cc9f67a to 0af21cb Compare September 23, 2024 16:46
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.

1 participant