diff --git a/CHANGELOG.md b/CHANGELOG.md index 80bd6ec8..50fbfde2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed +* Deprecate using space id in `crud.len` (#255). + ## [0.13.0] - 29-08-22 ### Added diff --git a/README.md b/README.md index e5a3b1d4..873bcda1 100644 --- a/README.md +++ b/README.md @@ -1037,13 +1037,15 @@ local result, err = crud.len(space_name, opts) where: -* `space_name` (`string|number`) - name of the space as well - as numerical id of the space +* `space_name` (`string`) - name of the space * `opts`: * `timeout` (`?number`) - `vshard.call` timeout (in seconds) Returns number or nil with error. +Using space id instead of space name is also possible, but +deprecated and will be removed in future releases. + **Example:** Using `memtx`: diff --git a/crud/len.lua b/crud/len.lua index 1cceb2b9..3f6f7aaa 100644 --- a/crud/len.lua +++ b/crud/len.lua @@ -1,6 +1,7 @@ local checks = require('checks') local errors = require('errors') local vshard = require('vshard') +local log = require('log') local utils = require('crud.common.utils') local dev_checks = require('crud.common.dev_checks') @@ -43,6 +44,11 @@ function len.call(space_name, opts) opts = opts or {} + if type(space_name) == 'number' then + log.warn('Using space id in crud.len is deprecated and will be removed in future releases.' .. + 'Please, use space name instead.') + end + local space = utils.get_space(space_name, vshard.router.routeall()) if space == nil then return nil, LenError:new("Space %q doesn't exist", space_name)