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 Table Resource is_in ConditionExpression overwrites data if more than 1 item is in the value list #4032

Open
KidAmnesiac1 opened this issue Feb 26, 2024 · 0 comments
Labels
bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged.

Comments

@KidAmnesiac1
Copy link

Describe the bug

When using a ConditionalExpression is_in filter with more than one item in the filter value, the values used to filter overwrite data in the DynamoDB item

Expected Behavior

ConditionalExpressions should not change DynamoDB item

Current Behavior

Values in ConditionalExpression appear in DynamoDB item after update

Reproduction Steps

  • Create table via console called test_table with hash key test_key
  • Run the code below
import boto3
from boto3.dynamodb.conditions import Attr

ddb = boto3.resource("dynamodb").Table("test_table")

ddb.put_item(
    Item={
        "test_key": "foo-key",
        "filter_val": "foo",
        "val1": 123,
    },
)


resp = ddb.update_item(
    Key={"test_key": "foo-key"},
    UpdateExpression="SET #f1=:v1",
    ExpressionAttributeNames={"#f1": "val1"},
    ExpressionAttributeValues={":v1": 321},
    ConditionExpression=Attr("filter_val").is_in(["foo", "bar"]),
    ReturnValues="ALL_NEW",
)


print(resp["Attributes"])

# {'filter_val': 'foo', 'val1': 'bar', 'test_key': 'foo-key'}

see above the the value for val1 was originally set to 123, and was meant to be update to 321 but instead was updated to bar.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

1.34.49

Environment details (OS name and version, etc.)

Amazon Linux 2

@KidAmnesiac1 KidAmnesiac1 added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant