Skip to content
Snippets Groups Projects
Commit b32b20c6 authored by Georgiy Lebedev's avatar Georgiy Lebedev Committed by Serge Petrenko
Browse files

box: pass source tuple to `default_func` field option of `space:format`

Let's pass the source tuple received as the argument to DML to the
`default_func` field option of `space:format` to give users more
versatility and the opportunity to compute the field value using other
fields from the source tuple.

For the tuple argument, we create a tuple rather than pass a MsgPack
object for consistency with our other box APIs, even though it is
suboptimal in terms of performance.

We create the tuple argument with the empty default format, however, in the
future it is possible to create it with a `names_only=true` format so that
the source tuple can have the space format's data dictionary.

We create the tuple argument from the source tuple data, which implies the
following: (i) fields may not adhere to the space format; (ii) nil fields
are always nil (i.e., the `default` value and the `default_func` are
not used). (i) is because we can only validate the tuple after we finish
building it. (ii) is because trying to use the `default` value and the
`default_func` would have field build ordering ambiguity and would hurt
performance of field building.

Closes #9825

@TarantoolBot document
Title: Tuple argument of `default_func` field option of `space:format`
Product: Tarantool
Since: 3.2
Root documents: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/format/

The source tuple (i.e., the argument of DML) is now passed as a second
argument to the `default_func` field option of `space:format`.

See also tarantool/tarantool#9825 and [PRD](https://www.notion.so/tarantool/Pass-tuple-as-argument-to-field-s-default_func-8785637fb79f43e4b8ca729e75fc4582).

Please note that the tuple argument is created from the source tuple data,
which implies the following: (i) fields may not adhere to the space format;
(ii) nil fields are always nil (i.e., the `default` value and the
`default_func` are not used).
parent 2467e421
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment