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 working as expected #3542

Open
dariellbowo opened this issue Nov 11, 2022 · 0 comments
Open

DynamoDbIgnoreNulls is not working as expected #3542

dariellbowo opened this issue Nov 11, 2022 · 0 comments

Comments

@dariellbowo
Copy link

dariellbowo commented Nov 11, 2022

This is a duplicate of #3499

I am using DynamoDB Enhanced Client to update partial attribute.

Reproduction Steps

@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"

Originally posted by @dariellbowo in #3499 (comment)

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

No branches or pull requests

1 participant