Skip to content

Commit

Permalink
Allow to pass numerical space id
Browse files Browse the repository at this point in the history
  • Loading branch information
ligurio committed Jul 15, 2021
1 parent 98ec296 commit c717aa4
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 46 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ local result, err = crud.insert_object(space_name, object, opts)

where:

* `space_name` (`string`) - name of the space to insert an object
* `space_name` (`string|number`) - name or numerical id of the space to insert an object
* `tuple` / `object` (`table`) - tuple/object to insert
* `opts`:
* `timeout` (`?number`) - `vshard.call` timeout (in seconds)
Expand Down Expand Up @@ -110,7 +110,7 @@ local object, err = crud.get(space_name, key, opts)

where:

* `space_name` (`string`) - name of the space
* `space_name` (`string|number`) - name or numerical id of the space
* `key` (`any`) - primary key value
* `opts`:
* `fields` (`?table`) - field names for getting only a subset of fields
Expand Down Expand Up @@ -147,7 +147,7 @@ local object, err = crud.update(space_name, key, operations, opts)

where:

* `space_name` (`string`) - name of the space
* `space_name` (`string|number`) - name or numerical id of the space
* `key` (`any`) - primary key value
* `operations` (`table`) - update [operations](https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/#box-space-update)
* `opts`:
Expand Down Expand Up @@ -180,7 +180,7 @@ local object, err = crud.delete(space_name, key, opts)

where:

* `space_name` (`string`) - name of the space
* `space_name` (`string|number`) - name or numerical id of the space
* `key` (`any`) - primary key value
* `opts`:
* `timeout` (`?number`) - `vshard.call` timeout (in seconds)
Expand Down Expand Up @@ -214,7 +214,7 @@ local result, err = crud.replace_object(space_name, object, opts)

where:

* `space_name` (`string`) - name of the space
* `space_name` (`string|number`) - name or numerical id of the space
* `tuple` / `object` (`table`) - tuple/object to insert or replace exist one
* `opts`:
* `timeout` (`?number`) - `vshard.call` timeout (in seconds)
Expand Down Expand Up @@ -261,7 +261,7 @@ local result, err = crud.upsert_object(space_name, tuple, operations, opts)

where:

* `space_name` (`string`) - name of the space
* `space_name` (`string|number`) - name or numerical id of the space
* `tuple` / `object` (`table`) - tuple/object to insert if there is no existing tuple which matches the key fields
* `operations` (`table`) - update [operations](https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/#box-space-update) if there is an existing tuple which matches the key fields of tuple
* `opts`:
Expand Down Expand Up @@ -312,7 +312,7 @@ local objects, err = crud.select(space_name, conditions, opts)

where:

* `space_name` (`string`) - name of the space
* `space_name` (`string|number`) - name or numerical id of the space
* `conditions` (`?table`) - array of [select conditions](#select-conditions)
* `opts`:
* `first` (`?number`) - the maximum count of the objects to return.
Expand Down Expand Up @@ -464,7 +464,7 @@ local result, err = crud.truncate(space_name, opts)

where:

* `space_name` (`string`) - name of the space
* `space_name` (`string|number`) - name or numerical id of the space
* `opts`:
* `timeout` (`?number`) - `vshard.call` timeout (in seconds)

Expand Down
8 changes: 4 additions & 4 deletions crud/borders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local STAT_FUNC_NAME = '_crud.get_border_on_storage'


local function get_border_on_storage(border_name, space_name, index_name, field_names)
dev_checks('string', 'string', 'string|number', '?table')
dev_checks('string', 'string|number', 'string|number', '?table')

assert(border_name == 'min' or border_name == 'max')

Expand Down Expand Up @@ -67,7 +67,7 @@ else
end

local function call_get_border_on_router(border_name, space_name, index_name, opts)
checks('string', 'string', '?string|number', {
checks('string', 'string|number', '?string|number', {
timeout = '?number',
fields = '?table',
})
Expand Down Expand Up @@ -161,7 +161,7 @@ end
-- @function min
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param ?string index_name
-- An index name as well as numerical id (by default, primary index is used)
Expand All @@ -184,7 +184,7 @@ end
-- @function min
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param ?string index_name
-- An index name as well as numerical id (by default, primary index is used)
Expand Down
8 changes: 4 additions & 4 deletions crud/delete.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local delete = {}
local DELETE_FUNC_NAME = '_crud.delete_on_storage'

local function delete_on_storage(space_name, key, field_names)
dev_checks('string', '?', '?table')
dev_checks('string|number', '?', '?table')

local space = box.space[space_name]
if space == nil then
Expand All @@ -38,7 +38,7 @@ end
-- need_reload indicates if reloading schema could help
-- see crud.common.schema.wrap_func_reload()
local function call_delete_on_router(space_name, key, opts)
dev_checks('string', '?', {
dev_checks('string|number', '?', {
timeout = '?number',
bucket_id = '?number|cdata',
fields = '?table',
Expand Down Expand Up @@ -84,7 +84,7 @@ end
-- @function call
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param key
-- Primary key value
Expand All @@ -101,7 +101,7 @@ end
-- @treturn[2] table Error description
--
function delete.call(space_name, key, opts)
checks('string', '?', {
checks('string|number', '?', {
timeout = '?number',
bucket_id = '?number|cdata',
fields = '?table',
Expand Down
8 changes: 4 additions & 4 deletions crud/get.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local get = {}
local GET_FUNC_NAME = '_crud.get_on_storage'

local function get_on_storage(space_name, key, field_names)
dev_checks('string', '?', '?table')
dev_checks('string|number', '?', '?table')

local space = box.space[space_name]
if space == nil then
Expand All @@ -38,7 +38,7 @@ end
-- need_reload indicates if reloading schema could help
-- see crud.common.schema.wrap_func_reload()
local function call_get_on_router(space_name, key, opts)
dev_checks('string', '?', {
dev_checks('string|number', '?', {
timeout = '?number',
bucket_id = '?number|cdata',
fields = '?table',
Expand Down Expand Up @@ -94,7 +94,7 @@ end
-- @function call
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param key
-- Primary key value
Expand All @@ -117,7 +117,7 @@ end
-- @treturn[2] table Error description
--
function get.call(space_name, key, opts)
checks('string', '?', {
checks('string|number', '?', {
timeout = '?number',
bucket_id = '?number|cdata',
fields = '?table',
Expand Down
12 changes: 6 additions & 6 deletions crud/insert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local insert = {}
local INSERT_FUNC_NAME = '_crud.insert_on_storage'

local function insert_on_storage(space_name, tuple, opts)
dev_checks('string', 'table', {
dev_checks('string|number', 'table', {
add_space_schema_hash = '?boolean',
fields = '?table',
})
Expand Down Expand Up @@ -44,7 +44,7 @@ end
-- need_reload indicates if reloading schema could help
-- see crud.common.schema.wrap_func_reload()
local function call_insert_on_router(space_name, tuple, opts)
dev_checks('string', 'table', {
dev_checks('string|number', 'table', {
timeout = '?number',
bucket_id = '?number|cdata',
add_space_schema_hash = '?boolean',
Expand Down Expand Up @@ -97,7 +97,7 @@ end
-- @function tuple
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param table tuple
-- Tuple
Expand All @@ -114,7 +114,7 @@ end
-- @treturn[2] table Error description
--
function insert.tuple(space_name, tuple, opts)
checks('string', 'table', {
checks('string|number', 'table', {
timeout = '?number',
bucket_id = '?number|cdata',
add_space_schema_hash = '?boolean',
Expand All @@ -129,7 +129,7 @@ end
-- @function object
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param table obj
-- Object
Expand All @@ -142,7 +142,7 @@ end
-- @treturn[2] table Error description
--
function insert.object(space_name, obj, opts)
checks('string', 'table', '?table')
checks('string|number', 'table', '?table')

opts = opts or {}

Expand Down
12 changes: 6 additions & 6 deletions crud/replace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local replace = {}
local REPLACE_FUNC_NAME = '_crud.replace_on_storage'

local function replace_on_storage(space_name, tuple, opts)
dev_checks('string', 'table', {
dev_checks('string|number', 'table', {
add_space_schema_hash = '?boolean',
fields = '?table',
})
Expand Down Expand Up @@ -44,7 +44,7 @@ end
-- need_reload indicates if reloading schema could help
-- see crud.common.schema.wrap_func_reload()
local function call_replace_on_router(space_name, tuple, opts)
dev_checks('string', 'table', {
dev_checks('string|number', 'table', {
timeout = '?number',
bucket_id = '?number|cdata',
add_space_schema_hash = '?boolean',
Expand Down Expand Up @@ -101,7 +101,7 @@ end
-- @function tuple
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param table tuple
-- Tuple
Expand All @@ -118,7 +118,7 @@ end
-- @treturn[2] table Error description
--
function replace.tuple(space_name, tuple, opts)
checks('string', 'table', {
checks('string|number', 'table', {
timeout = '?number',
bucket_id = '?number|cdata',
add_space_schema_hash = '?boolean',
Expand All @@ -133,7 +133,7 @@ end
-- @function object
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param table obj
-- Object
Expand All @@ -146,7 +146,7 @@ end
-- @treturn[2] table Error description
--
function replace.object(space_name, obj, opts)
checks('string', 'table', '?table')
checks('string|number', 'table', '?table')

opts = opts or {}

Expand Down
2 changes: 1 addition & 1 deletion crud/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function checkers.vshard_call_mode(p)
end

local function select_on_storage(space_name, index_name, conditions, opts)
dev_checks('string', 'string|number', '?table', {
dev_checks('string|number', 'string|number', '?table', {
scan_value = 'table',
after_tuple = '?table',
tarantool_iter = 'number',
Expand Down
6 changes: 3 additions & 3 deletions crud/truncate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local truncate = {}
local TRUNCATE_FUNC_NAME = '_crud.truncate_on_storage'

local function truncate_on_storage(space_name)
dev_checks('string')
dev_checks('string|number')

local space = box.space[space_name]
if space == nil then
Expand All @@ -31,7 +31,7 @@ end
-- @function call
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @tparam ?number opts.timeout
-- Function call timeout
Expand All @@ -41,7 +41,7 @@ end
-- @treturn[2] table Error description
--
function truncate.call(space_name, opts)
checks('string', {
checks('string|number', {
timeout = '?number',
})

Expand Down
8 changes: 4 additions & 4 deletions crud/update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local update = {}
local UPDATE_FUNC_NAME = '_crud.update_on_storage'

local function update_on_storage(space_name, key, operations, field_names)
dev_checks('string', '?', 'table', '?table')
dev_checks('string|number', '?', 'table', '?table')

local space = box.space[space_name]
if space == nil then
Expand Down Expand Up @@ -60,7 +60,7 @@ end
-- need_reload indicates if reloading schema could help
-- see crud.common.schema.wrap_func_reload()
local function call_update_on_router(space_name, key, user_operations, opts)
dev_checks('string', '?', 'table', {
dev_checks('string|number', '?', 'table', {
timeout = '?number',
bucket_id = '?number|cdata',
fields = '?table',
Expand Down Expand Up @@ -120,7 +120,7 @@ end
-- @function call
--
-- @param string space_name
-- A space name
-- A space name as well as numerical id
--
-- @param key
-- Primary key value
Expand All @@ -141,7 +141,7 @@ end
-- @treturn[2] table Error description
--
function update.call(space_name, key, user_operations, opts)
checks('string', '?', 'table', {
checks('string|number', '?', 'table', {
timeout = '?number',
bucket_id = '?number|cdata',
fields = '?table',
Expand Down
Loading

0 comments on commit c717aa4

Please sign in to comment.