Skip to content

lua/key_def: add key validation and comparison functions#9868

Merged
locker merged 1 commit intotarantool:masterfrom
locker:lua-key-def-new-methods
Mar 27, 2024
Merged

lua/key_def: add key validation and comparison functions#9868
locker merged 1 commit intotarantool:masterfrom
locker:lua-key-def-new-methods

Conversation

@locker
Copy link
Member

@locker locker commented Mar 25, 2024

The following new functions were introduced to the key_def Lua module:

  • key_def:validate_key(key): validates a key against a key definition object. Raises an exception if the key doesn't match. Returns nothing on success. See also box_key_def_validate_key C API function.

  • key_def:validate_full_key(key): validates a full key against a key definition object. Raises an exception if the key doesn't match. Returns nothing on success. See also box_key_def_validate_full_key C API function.

  • key_def:validate_tuple(tuple): validates a tuple against a key definition object. Raises an exception if the tuple doesn't match. Returns nothing on success. See also box_key_def_validate_tuple C API function.

  • key_def:compare_keys(key_a, key_b): compares two keys according to a key definition object. Raises an exception if any of the given key doesn't match the key definition. On success, returns a value <0 if key_a parts are less than key_b parts, 0 if equal, >1 if greater.

Closes #9863

@locker locker requested review from a team as code owners March 25, 2024 15:52
@locker locker requested a review from Totktonada March 25, 2024 15:56
@coveralls
Copy link

coveralls commented Mar 25, 2024

Coverage Status

coverage: 87.034% (+0.02%) from 87.014%
when pulling 1b2517c on locker:lua-key-def-new-methods
into 6980007
on tarantool:master
.

@Totktonada Totktonada assigned locker and unassigned Totktonada Mar 26, 2024
Closes tarantool#9863

@TarantoolBot document
Title: Document key validation and comparison `key_def` module functions

The following new functions were introduced to the `key_def` Lua module:

 - `key_def:validate_key(key)`: validates a key against a key definition
   object. Raises an exception if the key doesn't match. Returns nothing
   on success. See also `box_key_def_validate_key` C API function.

 - `key_def:validate_full_key(key)`: validates a full key against a key
   definition object. Raises an exception if the key doesn't match.
   Returns nothing on success. See also `box_key_def_validate_full_key`
   C API function.

 - `key_def:validate_tuple(tuple)`: validates a tuple against a key
   definition object. Raises an exception if the tuple doesn't match.
   Returns nothing on success. See also `box_key_def_validate_tuple`
   C API function.

 - `key_def:compare_keys(key_a, key_b)`: compares two keys according to
   a key definition object. Raises an exception if any of the given key
   doesn't match the key definition. On success, returns a value <0 if
   `key_a` parts are less than `key_b` parts, 0 if equal, >0 if greater.
@locker locker force-pushed the lua-key-def-new-methods branch from 070590c to 1b2517c Compare March 26, 2024 13:57
@locker locker added the full-ci Enables all tests for a pull request label Mar 26, 2024
@locker locker merged commit 7e5881e into tarantool:master Mar 27, 2024
@locker locker deleted the lua-key-def-new-methods branch March 27, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Enables all tests for a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add functions for validation and comparison keys to key_def module

5 participants