-
Notifications
You must be signed in to change notification settings - Fork 403
Closed
Labels
Description
The only way to validate a tuple against a space format without inserting it into the space is using box.tuple.new with the format option:
tarantool> box.tuple.new({'a', 1}, {format = box.space._schema:format()})
---
- ['a', 1]
...
tarantool> box.tuple.new({1, 2}, {format = box.space._schema:format()})
---
- error: 'Tuple field 1 (key) type does not match one required by operation: expected
string, got unsigned'
...It'd be nice if a tuple format object had the validate method so that we wouldn't have to create a new tuple in this case:
local format = box.tuple.format.new({{'key', 'string'}, {'value', 'any'}})
format:validate({'a', 1}) -- ok
format:validate(box.tuple.new({'a', 1})) -- ok
format:validate({1, 2}) -- error
format:validate(box.tuple.new({1, 2})) -- errorSimilarly to index.parts, it should be possible to use validate with space.format:
box.space._schema.format -- returns format object
box.space._schema.format:validate({'a', 1}) -- ok
box.space._schema.format:validate(box.tuple.new({'a', 1})) -- ok
box.space._schema.format:validate({1, 2}) -- error
box.space._schema.format:validate(box.tuple.new({1, 2})) -- errorSimilar tickets for key_def and index.parts:
Reactions are currently unavailable