mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-07 07:23:15 +00:00
This patch adds full support for nested attribute paths (e.g., a.b[3].c) in UpdateExpression. After in previous patches we already added such support for ProjectionExpression, ConditionExpression and FilterExpression this means the nested attribute paths feature is now complete, so we remove the warning from the documents. However, there is one last loose end to tie and we will do it in the next patch: After this patch, the combination of UpdateExpression with nested attributes and ReturnValues is still wrong, and the test for it in test_returnvalues.py still xfails. Note that previous patches already implemented support for attribute paths in expression evaluations - i.e., the right-hand side of UpdateExpression actions, and in this patch we just needed to implement the left hand side: When an update action is on an attribute a.b we need to read the entire content of the top-level a (an RWM operation), modify just the b part of its json with the result of the action, and finally write back the entire content of a. Of course everything gets complicated by the fact that we can have multiple actions on multiple pieces of the same JSON, and we also need to detect overlapping and conflicting actions (we already have this detection in the attribute_path_map<> class we introduced in a previous patch). I decided to leave one small esoteric difference, reproduced by the xfailing test_update_expression.py::test_nested_attribute_remove_from_missing_item: As expected, "SET x.y = :val" fails for an item if its attribute x doesn't exist or the item itself does not exist. For the update expression "REMOVE x.y", DynamoDB fails if the attribute x doesn't exist, but oddly silently passes if the entire item doesn't exist. Alternator does not currently reproduce this oddity - it will fail this write as well. Signed-off-by: Nadav Har'El <nyh@scylladb.com>