diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 0999acf65e7b9f28f83cd8880da1f253c8eaa09b..27afec3505b2271b51b2b9a4c9ea1a26e0643d2d 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -443,19 +443,24 @@ end -- Change one-based indexing in update commands to zero-based. -- local function normalize_update_ops(ops) + if type(ops) ~= 'table' then + return ops; + end for _, op in ipairs(ops) do - if op[1] == ':' then - -- fix offset for splice - if op[3] > 0 then - op[3] = op[3] - 1 - elseif op[3] == 0 then - box.error(box.error.SPLICE, op[2], "offset is out of bound") + if type(op) == 'table' then + if op[1] == ':' then + -- fix offset for splice + if op[3] > 0 then + op[3] = op[3] - 1 + elseif op[3] == 0 then + box.error(box.error.SPLICE, op[2], "offset is out of bound") + end + end + if op[2] > 0 then + op[2] = op[2] - 1 + elseif op[2] == 0 then + box.error(box.error.NO_SUCH_FIELD, op[2]) end - end - if op[2] > 0 then - op[2] = op[2] - 1 - elseif op[2] == 0 then - box.error(box.error.NO_SUCH_FIELD, op[2]) end end return ops diff --git a/test/box/update.result b/test/box/update.result index 3dfddd5c53f2c213fe5f11a75d6fbe8a4962007c..b2b49e328484118f8bc65f7d4222f463e871c4fe 100644 --- a/test/box/update.result +++ b/test/box/update.result @@ -330,3 +330,25 @@ s:truncate() s:drop() --- ... +-- #521: Cryptic error message in update operation +s = box.schema.create_space('tweedledum') +--- +... +s:create_index('pk') +--- +... +s:insert{1, 2, 3} +--- +- [1, 2, 3] +... +s:update({1}) +--- +- error: Tuple/Key must be MsgPack array +... +s:update({1}, {'=', 1, 1}) +--- +- error: Invalid MsgPack - expected an update operation name (string) +... +s:drop() +--- +... diff --git a/test/box/update.test.lua b/test/box/update.test.lua index 4723fef896c924637a630a79d4c83aa47270c102..010721ce170bed04660c16ed85d7e2a84c153bb4 100644 --- a/test/box/update.test.lua +++ b/test/box/update.test.lua @@ -110,3 +110,11 @@ s = box.space.tweedledum s:select{} s:truncate() s:drop() + +-- #521: Cryptic error message in update operation +s = box.schema.create_space('tweedledum') +s:create_index('pk') +s:insert{1, 2, 3} +s:update({1}) +s:update({1}, {'=', 1, 1}) +s:drop()