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

DynamoDbIgnoreNulls is not respected #3499

Closed
chrylis opened this issue Oct 18, 2022 · 3 comments
Closed

DynamoDbIgnoreNulls is not respected #3499

chrylis opened this issue Oct 18, 2022 · 3 comments
Assignees
Labels
bug This issue is a bug. closed-for-staleness dynamodb-enhanced response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Comments

@chrylis
Copy link

chrylis commented Oct 18, 2022

Describe the bug

This is a duplicate of #2938, which was closed without being fixed.

I am using the DynamoDB Enhanced Client's @DynamoDbIgnoreNulls exactly as demonstrated in the documentation:

@DynamoDbBean
class Dispatch {
  @DynamoDbIgnoreNulls
  Status getStatus() { return status; }
}

When the Dispatch object is written using the enhanced client, all of the properties on Status with null values are written as AttributeValue(NUL=true) instead of omitted.

Expected Behavior

I expected null values not to be included at all.

Current Behavior

NUL attributes are inserted.

Reproduction Steps

@DynamoDbBean
class Status {
  String status
}

class Dispatch {
  Status status

  @DynamoDbIgnoreNulls
  Status getStatus() { return status; }
}

Possible Solution

The ignoreNulls flag appears not to be applied recursively.

Additional Information/Context

No response

AWS Java SDK version used

2.17.284

JDK version used

AdoptOpenJDK-11.0.11+9

Operating System and version

Gentoo Linux

@chrylis chrylis added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 18, 2022
@debora-ito debora-ito self-assigned this Oct 21, 2022
@debora-ito
Copy link
Member

Hi @chrylis apologies for the long delay in response here.

I'm not able to repro, can you share a sample code with the DynamodbEnhanced operation?

Are you using flattened beans?

@debora-ito debora-ito added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. dynamodb-enhanced and removed needs-triage This issue or PR still needs to be triaged. labels Oct 29, 2022
@github-actions
Copy link

github-actions bot commented Nov 3, 2022

It looks like this issue has not been active for more than five days. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please add a comment to prevent automatic closure, or if the issue is already closed please feel free to reopen it.

@github-actions github-actions bot added closing-soon This issue will close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will close in 4 days unless further comments are made. labels Nov 3, 2022
@github-actions github-actions bot closed this as completed Nov 5, 2022
@dariellbowo
Copy link

dariellbowo commented Nov 11, 2022

I am having the same issue with this configuration

@DynamoDbBean
public abstract class Parent {
    private Integer id;
    private Instant createdTimestamp;
    
    @DynamoDbPartitionKey
    @DynamoDbAttribute("id")
    public Integer getAccountId() {
        return id;
    }

    @DynamoDbAttribute("created_timestamp")
    @DynamoDbUpdateBehavior(UpdateBehavior.WRITE_IF_NOT_EXISTS)
    @DynamoDbAutoGeneratedTimestampAttribute
    public Instant getCreatedTimestamp() {
        return createdTimestamp;
    }
}
@DynamoDbBean
public class Child{
    private String attribute1;
    private String attribute2;

    @DynamoDbAttribute("attribute_1")
    @DynamoDbIgnoreNulls
    public String getAttribute1() {
        return attribute1;
    }

    @DynamoDbAttribute("attribute_2")
    @DynamoDbIgnoreNulls
    public String getAttribute2() {
        return attribute2;
    }
}

client = enhancedAsyncClient.table(tableName, TableSchema.fromBean(Child.class));

Child child = new Child(777, "someValue1", "someValue2");
client.updateItem(child);

Child updatedChild = new Child(777, "someValue3");
enhancedAsyncClient.table(tableName, TableSchema.fromBean(Child.class)).updateItem(child);
client.updateItem(updatedChild);
// After this statement attribute2 will be empty while attribute1 is updated to "someValue3"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness dynamodb-enhanced response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.
Projects
None yet
Development

No branches or pull requests

3 participants