commit 3e1c2772f68e3e360dc168ced8ba6b1f578f360c from: Nikolay Shirokovskiy via: Aleksandr Lyapunov date: Thu Jun 29 14:53:58 2023 UTC update: add tests related to multiple update to the same field These are misc tests that can be related to the issue. Not sure all of them do not work before the patch set for the issue. It is nice to have them and be sure everything works fine. Closes #8658 NO_DOC=minor commit - 7a8177bbc8bf6523044378205d8c8f2271be4d27 commit + 3e1c2772f68e3e360dc168ced8ba6b1f578f360c blob - /dev/null blob + 2bf18651a16e415ce9232cda1857624379a6d7a1 (mode 644) --- /dev/null +++ changelogs/unreleased/gh-8226-multiple-same-field-update.md @@ -0,0 +1,3 @@ +## feature/box + +* Allowed multiple updates to the same tuple field in a single call (gh-8226). blob - 260239380c8722314cb333116777886d0367bc83 blob + 5705179eca3ef440b2eaae93c154aba4207d5981 --- test/box/update.result +++ test/box/update.result @@ -2606,4 +2606,50 @@ t:update({{'+', '[2].a', 1}, {'!', '[2].b', {x = 2, y t:update({{'+', '[2].a', 1}, {'!', '[2].b', {x = 2, y = 3}}, {'=', '[2].b.y', 4}}) --- - [7, {'b': {'y': 4, 'x': 2}, 'a': 2}, 11] +... +-- Test removing field and then inserting it +t = box.tuple.new({7, 5, 11}) +--- +... +t:update({{'#', 2, 1}, {'!', 2, 6}}) +--- +- [7, 6, 11] +... +t = box.tuple.new{7, {a = 2, b = 5}, 11} +--- +... +t:update({{'+', '[2].a', 2}, {'#', '[2].b', 1}, {'!', '[2].b', 6}}) +--- +- [7, {'b': 6, 'a': 4}, 11] +... +t:update({{'#', '[2].b', 1}, {'!', '[2].b', 6}}) +--- +- [7, {'b': 6, 'a': 2}, 11] +... +-- Test inserting field and then removing it +t = box.tuple.new({7, 11}) +--- +... +t:update({{'!', 2, 5}, {'#', 2, 1}}) +--- +- [7, 11] ... +t = box.tuple.new({7, {a = 2}, 11}) +--- +... +t:update({{'+', '[2].a', 2}, {'!', '[2].b', 7}, {'#', '[2].b', 1}}) +--- +- [7, {'a': 4}, 11] +... +t:update({{'!', '[2].b', 7}, {'#', '[2].b', 1}}) +--- +- [7, {'a': 2}, 11] +... +-- Test bar insert of non scalar value and then changing inside it +t = box.tuple.new({7, {a = {a = 2}}, 11}) +--- +... +t:update({{'!', '[2].a.b', {x = {x = {y = 2}}}}, {'+', '[2].a.b.x.x.y', 2}}) +--- +- [7, {'a': {'b': {'x': {'x': {'y': 4}}}, 'a': 2}}, 11] +... blob - 9e2abfb6672ef99f75984b4920be219ffe4f3e05 blob + adcbe2e101941e1b371ae27f0a14e6c33ebb666f --- test/box/update.test.lua +++ test/box/update.test.lua @@ -956,3 +956,18 @@ t:update({{'+', '[2].a', 1}, {'!', '[2].b', {x = 2}}, t:update({{'+', '[2].a', 1}, {'!', '[2].b', {x = 2}}, {'!', '[2].b.y', 3}}) t:update({{'+', '[2].a', 1}, {'!', '[2].b', {x = 2, y = 3}}, {'#', '[2].b.y', 1}}) t:update({{'+', '[2].a', 1}, {'!', '[2].b', {x = 2, y = 3}}, {'=', '[2].b.y', 4}}) +-- Test removing field and then inserting it +t = box.tuple.new({7, 5, 11}) +t:update({{'#', 2, 1}, {'!', 2, 6}}) +t = box.tuple.new{7, {a = 2, b = 5}, 11} +t:update({{'+', '[2].a', 2}, {'#', '[2].b', 1}, {'!', '[2].b', 6}}) +t:update({{'#', '[2].b', 1}, {'!', '[2].b', 6}}) +-- Test inserting field and then removing it +t = box.tuple.new({7, 11}) +t:update({{'!', 2, 5}, {'#', 2, 1}}) +t = box.tuple.new({7, {a = 2}, 11}) +t:update({{'+', '[2].a', 2}, {'!', '[2].b', 7}, {'#', '[2].b', 1}}) +t:update({{'!', '[2].b', 7}, {'#', '[2].b', 1}}) +-- Test bar insert of non scalar value and then changing inside it +t = box.tuple.new({7, {a = {a = 2}}, 11}) +t:update({{'!', '[2].a.b', {x = {x = {y = 2}}}}, {'+', '[2].a.b.x.x.y', 2}})