Repository navigation
Conversation
…erated-key-annotation' into feature/define-dynamo-db-autogenerated-key-annotation
…erated-key-annotation' into feature/define-dynamo-db-autogenerated-key-annotation
…-annotation # Conflicts: # services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java
…erated-key-annotation' into feature/define-dynamo-db-autogenerated-key-annotation # Conflicts: # services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/extensions/annotations/DynamoDbAutoGenerateStrategy.java # services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/extensions/annotations/DynamoDbAutoGeneratedUuid.java
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds strategy-based UUID generation to
@DynamoDbAutoGeneratedUuid, following the V1 strategy model from@DynamoDBGeneratedUuid(DynamoDBAutoGenerateStrategy):strategy = ALWAYS(default): generate a new UUID on every writestrategy = CREATE: generate a UUID only when the attribute is missingFor a non-key
CREATEattribute omitted from anupdateItem, the extension lets DynamoDB check the stored item:This prevents a partial update from overwriting an existing value just because the caller omitted the field.
Important Rules
@DynamoDbAutoGeneratedUuidis valid only forStringattributes.CREATEworks for key and non-key attributes. A missing primary key is generated in the item map becauseupdateItemrequires it.ALWAYSremains the default, preserving existing behavior.NULLis missing and an empty string is present.putItemis a full replacement. Repeating a put with the same key and noCREATEvalue generates a new UUID.@DynamoDbIgnoreNullsbehavior are out of scope. Flattened UUID attributes are supported.Ignore-Null Behavior for a Top-Level, Non-Key
CREATEUUIDignoreNulls(true)ignoreNulls(true)if_not_existsignoreNulls(true)NULLNULLis preserved because the attribute existsignoreNulls(true)IgnoreNullsMode.MAPS_ONLYNULL/ emptyNULL, and empty strings are preserved; a UUID is generated only when the stored attribute is absentIgnoreNullsMode.SCALAR_ONLYNULL/ emptyNULL, and empty strings are preserved; a UUID is generated only when the stored attribute is absentignoreNulls(false)NULLIgnoreNullsMode.DEFAULTNULLUpdateBehavior Notes
@DynamoDbUpdateBehavioraffectsUpdateItemexpression construction, not UUID strategy selection orPutItem. Omitted non-keyCREATEvalues use the extension'sif_not_existsaction; caller-provided values use the normal update expression.Motivation and Context
This PR addresses #5497. Instead of adding a separate
@DynamoDbAutoGeneratedKeyAPI, it addsALWAYSandCREATEstrategies to the existing UUID annotation.ALWAYSstays the default for backward compatibility, whileCREATEprovides generate-only-when-missing behavior.Modifications
DynamoDbAutoGenerateStrategywithALWAYSandCREATE.strategyto@DynamoDbAutoGeneratedUuid, defaulting toALWAYS.AutoGeneratedUuidTagandAutoGeneratedUuidExtensionto carry and apply the strategy per attribute.if_not_existsSET action for omitted, non-keyCREATEfields duringupdateItem. Multiple omitted fields are supported.Testing
Tests cover:
ALWAYSandCREATEfor key and non-key attributes.NULL, and empty-string values.ignoreNulls(true/false)and allIgnoreNullsModevalues.putItem, multiple omittedCREATEattributes, update behavior, extension ordering, shared clients, flattened schemas, and mixed-schema batch/transaction operations.Local results:
dynamodb-enhancedmodule: 3,637 tests, 0 failures/errorsTest Coverage on modified classes:
Test Coverage Checklist
@DynamoDbIgnoreNullsis out of scope@DynamoDbIgnoreNullsis out of scope@DynamoDbIgnoreNullsis out of scopeCREATEand non-keyCREATECREATEpreserve/generate behavior, all request-level ignore-null modes, and stored-state matrixCREATEpreserve/generate behaviorNULLgenerates; omitted value usesif_not_exists@DynamoDbAutoGeneratedUuidsupportsStringonly)@DynamoDbAutoGeneratedUuidsupportsStringonly)NULLgenerates; omitted storedNULLand empty string are preservedALWAYS, non-keyCREATE, omitted existing/absent states, flatten, and shared client@DynamoDbAutoGeneratedUuiddefaults toALWAYSCREATE+ document on one clientCREATEbean still generatesdefaultExtensions+ UUIDVersionedRecordExtensionis coveredWRITE_ALWAYS,WRITE_IF_NOT_EXISTS)CREATEpreserve/generate behaviorCREATEpreserved;ALWAYSregenerated on updateCREATE/ALWAYSGSI keysALWAYSgenerate/regenerateCREATEbean + documentTypes of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License