Skip to content

Conversation

dagnir
Copy link
Contributor

@dagnir dagnir commented Aug 20, 2025

Motivation and Context

In DynamoDB, the "NULL" member of AttributeValue is customized to "NUL" because "null" is a reserved keyword. This has the effect of generating nul() and getNul() as getters, and nul(Boolean), and setNul(Boolean) as setters for the serializable builder class.

If using the serializable builder class to map from a JSON string with the correct property name "NULL", it will not be recognized.

To fix this, generate an additional setter with the correct name setNull().

To make this work, ModifyModelShapeModifier has been updated with a new option called alternateBeanPropertyName. When set, for the modified member, we will generate an additional bean style setter on the model builder using the given property name.

Diff of generated code. Adds a setNull that behaves exactly like setNul.

--- attributevalue-old.java     2025-08-20 15:03:41
+++ attributevalue-new.java     2025-08-20 15:01:46
@@ -1340,6 +1340,12 @@
         }

         public final void setNul(Boolean nul) {
+            Object oldValue = this.nul;
+            this.nul = nul;
+            handleUnionValueChange(Type.NUL, oldValue, this.nul);
+        }
+
+        public final void setNull(Boolean nul) {
             Object oldValue = this.nul;
             this.nul = nul;
             handleUnionValueChange(Type.NUL, oldValue, this.nul);

Modifications

Testing

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

@dagnir dagnir force-pushed the dongie/ddb-null-attribute branch 2 times, most recently from 181a23a to 7150b6c Compare August 20, 2025 21:18
@dagnir dagnir marked this pull request as ready for review August 20, 2025 21:18
@dagnir dagnir requested a review from a team as a code owner August 20, 2025 21:18
In DynamoDB, the "NULL" member of AttributeValue is customized to "NUL"
because "null" is a reserved keyword. This has the effect of generating
nul() and getNul() as getters, and nul(Boolean), and setNul(Boolean) as
setters for the serializable builder class.

If using the serializable builder class to map from a JSON string with
the correct property name "NULL", it will not be recognized.

To fix this, generate an additional setter with the correct name
getNull().

To make this work, `ModifyModelShapeModifier` has been updated with a
new option called `alternateBeanPropertyName`. When set, for the
modified member, we will generate an additional bean style setter on the
model builder using the given property name.
@dagnir dagnir force-pushed the dongie/ddb-null-attribute branch from 7150b6c to 079a67c Compare August 20, 2025 21:28
Copy link

@dagnir dagnir added this pull request to the merge queue Aug 21, 2025
Merged via the queue into master with commit c5e7b64 Aug 21, 2025
36 of 38 checks passed
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants