diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc index d0a7e7815fd6ec5304ff0fc8715e3b3110edaeb7..da363c48271b673b4920ba3c7fde2a4c53f8440e 100644 --- a/src/box/lua/space.cc +++ b/src/box/lua/space.cc @@ -576,14 +576,18 @@ lbox_space_frommap(struct lua_State *L) } lua_rawseti(L, -3, fieldno+1); } - if (table) - return 1; lua_replace(L, 1); lua_settop(L, 1); tuple = luaT_tuple_new(L, -1, space->format); - if (tuple == NULL) - return luaT_error(L); + if (tuple == NULL) { + struct error *e = diag_last_error(&fiber()->diag); + lua_pushnil(L); + lua_pushstring(L, e->errmsg); + return 2; + } + if (table) + return 1; luaT_pushtuple(L, tuple); return 1; usage_error: diff --git a/test/box/tuple.result b/test/box/tuple.result index 1082ae84e919445346f5852d47b77558326d6fd5..5321ca488c92b55cc6fbf607df2457cbce628341 100644 --- a/test/box/tuple.result +++ b/test/box/tuple.result @@ -1121,7 +1121,13 @@ s:frommap() ... s:frommap({}) --- -- error: Tuple field 1 required by space format is missing +- null +- Tuple field 1 required by space format is missing +... +s:frommap({ddd = 'fail', aaa = 2, ccc = 3, bbb = 4}, {table=true}) +--- +- null +- 'Tuple field 4 type does not match one required by operation: expected unsigned' ... s:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true}) --- diff --git a/test/box/tuple.test.lua b/test/box/tuple.test.lua index 8dd15a0a1072b032f472b07459ab500ff7cade7d..3a77c43ed5cbf8adf4c96c1ad10ac286c0be86e5 100644 --- a/test/box/tuple.test.lua +++ b/test/box/tuple.test.lua @@ -373,6 +373,7 @@ s:frommap({ddd = 1, aaa = 2, bbb = 3}) s:frommap({ddd = 1, aaa = 2, ccc = 3, eee = 4}) s:frommap() s:frommap({}) +s:frommap({ddd = 'fail', aaa = 2, ccc = 3, bbb = 4}, {table=true}) s:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true}) s:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = false}) s:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = box.NULL})