tuple format: don't allow null where array/map is expected
If an indexed field expects array/map, it shouldn't be allowed to insert null instead, because this might break expectations of field accessors. For unikey indexes inserting null instead of array/map works fine though somewhat confusing: for a non-nullable field you get a wrong error message ("field is missing" instead of "array/map expected, got nil"); for a nullable field, this silently works, just looks weird as there's a clear type mismatch here. However, for a multikey field you get a crash as tuple_multikey_count() doesn't expect to see null where an array should be according to the format: tuple_raw_multikey_count: Assertion `mp_typeof(*array_raw) == MP_ARRAY' failed. This issue exists, because we assume all fields are nullable by default for some reason. Fix that and add some tests. Note, you can still omit nullable fields, e.g. if field "[2].a[1]" is nullable you may insert tuple [1, {a = {}}] or [1, {b = 1}] or even [1], you just can't pass box.NULL instead of an array/map.
Showing
- src/box/tuple_format.c 1 addition, 1 deletionsrc/box/tuple_format.c
- test/engine/json.result 81 additions, 2 deletionstest/engine/json.result
- test/engine/json.test.lua 25 additions, 2 deletionstest/engine/json.test.lua
- test/engine/multikey.result 58 additions, 0 deletionstest/engine/multikey.result
- test/engine/multikey.test.lua 19 additions, 0 deletionstest/engine/multikey.test.lua
Loading
Please register or sign in to comment