Skip to content

Commit

Permalink
update: add tests related to multiple update to the same field
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nshy authored and alyapunov committed Jun 29, 2023
1 parent 7a8177b commit 3e1c277
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/unreleased/gh-8226-multiple-same-field-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## feature/box

* Allowed multiple updates to the same tuple field in a single call (gh-8226).
46 changes: 46 additions & 0 deletions test/box/update.result
Original file line number Diff line number Diff line change
Expand Up @@ -2607,3 +2607,49 @@ 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]
...
15 changes: 15 additions & 0 deletions test/box/update.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -956,3 +956,18 @@ t:update({{'+', '[2].a', 1}, {'!', '[2].b', {x = 2}}, {'+', '[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}})

0 comments on commit 3e1c277

Please sign in to comment.