Closed onhate closed 4 years ago
In an operation where you have the same field on update clause and where clause, the value on the where clause overwrites the values from the update.
await Table.update({id: '5'}, {$set: {foo: null}}).where({foo: 'bar'}).exec();
I would expect the query to be something like this:
{ TableName: 'Table', ReturnValues: 'ALL_NEW', Key: { id: '5' }, UpdateExpression: 'SET #k_foo=:v_foo', ExpressionAttributeNames: { '#k_foo': 'foo', '#k_id': 'id' }, ExpressionAttributeValues: { ':v_foo': null, ':v_foo_1': 'bar', ':v_id': '5' }, ConditionExpression: '(#k_id=:v_id) AND (#k_foo=:v_foo_1)' }
but it comes as this, and instead of setting the foo value to null it sets it back to bar.
foo
bar
{ TableName: 'Table', ReturnValues: 'ALL_NEW', Key: { id: '5' }, UpdateExpression: 'SET #k_foo=:v_foo', ExpressionAttributeNames: { '#k_foo': 'foo', '#k_id': 'id' }, ExpressionAttributeValues: { ':v_foo': 'bar', ':v_id': '5' }, ConditionExpression: '(#k_id=:v_id) AND (#k_foo=:v_foo)' }
In an operation where you have the same field on update clause and where clause, the value on the where clause overwrites the values from the update.
I would expect the query to be something like this:
but it comes as this, and instead of setting the
foo
value to null it sets it back tobar
.