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 flattened prefixing  #5601

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

Conversation

akiesler
Copy link
Contributor

This pull request adds the ability for flattened beans to have a prefix attached to their flattened attributes. This enables clients to avoid conflicts in field names with flattening Beans with the same attribute name. This change supports 3 modes of setting the prefix.

  1. Explicitly setting the prefix on the annotation.
  2. Determine the prefix from the existing attribute name.
  3. Determine the prefix from the @DynamoDbAttribute annotation.

Motivation and Context

We regularly use an Edit Bean containing an actor and timestamp to track both creation and updates.
When flattening the fields we experience a conflict as both beans share the same attributes.

Reference: #3695

Modifications

Modified Static Table Schema to enable setting the prefixes programmatically.
Modified Bean Schema builders to determine prefixes from @DynamoDbFlatten annotations.

Testing

Implemented Unit Tests to ensure that prefixing logic worked as expected.

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 16, 2024 19:46
@akiesler
Copy link
Contributor Author

Build is failing because of the japicmp target. Would appreciate insights on how to address this issue.

Failed to execute goal com.github.siom79.japicmp:japicmp-maven-plugin:0.15.6:cmp (default) on project dynamodb-enhanced: There is at least one incompatibility: software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbFlatten.prefix():METHOD_ABSTRACT_ADDED_TO_CLASS 

Andy Kiesler added 2 commits September 23, 2024 09:46
This allows clients to specify a prefix when flattening a schema to ensure
that there are no conflicts between field names.
This makes enables clients to avoid conflicts if flattened schemas happen
to share a field name. The design maintains backwards compatibility with
existing codebases by requiring that users opt-in to this behavior
explicitly. While this increases the mental overhead there is a design
to enable the auto-prefixing as the default behavior when creating the
mapper. However, that is outside of the scope of this current implementation.
@akiesler akiesler force-pushed the dynamodb-enhanced-flattened-prefixing  branch from 0aec8f1 to 9a8bbd7 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