Conversation
|
|
|
Oh, wait, that line of code is indeed it prevents item field values |
| ConditionExpression: '#a IN (:a)', | ||
| UpdateExpression: 'SET #a = :b', | ||
| ExpressionAttributeNames: {'#a': 'active'}, | ||
| ExpressionAttributeValues: {':a': {BOOL: false}, ':b': {BOOL: true}}, |
There was a problem hiding this comment.
To make test cases comprehensive, consider adding all kinds of JS falsy things: false, null, 0, 0.0, ""
There was a problem hiding this comment.
Added another test for those values. null and 0/0.0 don't fail because they're encoded as {NULL:true} and {N: "0"} respectively, so their "attrVal" becomes true and "0".
The one that confuses me as to how it didn't fail is "" ({S:""}) because I feel like that should have the same issue but doesn't for reasons I cannot understand.
| ExpressionAttributeValues: {':t': {BOOL: true}, ':v': value}, | ||
| }), function(err, res) { | ||
| if (err) return cb(err) | ||
| res.statusCode.should.equal(200, `Update failed when checking for {${Object.keys(value)[0]}:${Object.values(value)[0]}}`) |
There was a problem hiding this comment.
I'd use JSON.stringify(value) over custom keys/values
dynalite incorrectly rejects condition expressions when using
INwithfalse.For example, if we have an item
{key: {S: "key"}, val: {BOOL: false}}and do an update with a condition expression{ConditionExpression: "#v IN (:f)", ExpressionAttributeNames: {"#v": "val"}, ExpressionAttributeValues: {":f": {BOOL: false}}it will fail with conditional check failed, even though it should match (tested against real AWS DynamoDB and dynamodb-local).I tried to fix it myself but unfortunately my JS skills proved to be insufficient, but I did manage to write a test that illustrates the issue, so hopefully someone else can write the actual fix for it.I figured out a fix, but I don't fully understand this whole code base so I'm not sure if the line I removed to fix this is somehow needed for other things to work