<HTML><BODY><div><div><div>Make error on box.sequence.<sequence_ex>.<method> call<br>similar to space error.<br>Ex: 'Use sequence:next(...) instead of sequence.next(...)'.</div><div>Closes #4754<br>---</div><div> </div><div>Github: https://github.com/VifleY/tarantool/tree/dkoltsov-fix-gh4754<br>Issue: https://github.com/tarantool/tarantool/issues/4754</div><div> </div><div> src/box/lua/schema.lua | 19 +++++++++++++++++++<br> test/box/sequence.result | 30 ++++++++++++++++++++++++++++++<br> test/box/sequence.test.lua | 12 ++++++++++++<br> 3 files changed, 61 insertions(+)</div><div>diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua<br>index 85fcca562..5fc3128c4 100644<br>--- a/src/box/lua/schema.lua<br>+++ b/src/box/lua/schema.lua<br>@@ -1809,14 +1809,25 @@ function box.schema.space.bless(space)<br> end<br> end<br> <br>+-- Helper function to check sequnce:method() usage<br>+local function check_sequence_arg(seq, method)<br>+ if type(seq) ~= 'table' or seq.id == nil then<br>+ local fmt = 'Use sequence:%s(...) instead of sequence.%s(...)'<br>+ error(string.format(fmt, method, method))<br>+ end<br>+end<br>+<br> local sequence_mt = {}<br> sequence_mt.__index = sequence_mt<br> <br> sequence_mt.next = function(self)<br>+ check_sequence_arg(self, 'next')<br> return internal.sequence.next(self.id)<br> end<br> <br> sequence_mt.current = function(self)<br>+ check_sequence_arg(self, 'current')<br>+<br> local ai64 = buffer.reg1.ai64<br> local rc = builtin.box_sequence_current(self.id, ai64)<br> if rc < 0 then<br>@@ -1826,18 +1837,26 @@ sequence_mt.current = function(self)<br> end<br> <br> sequence_mt.set = function(self, value)<br>+ check_sequence_arg(self, 'set')<br>+<br> return internal.sequence.set(self.id, value)<br> end<br> <br> sequence_mt.reset = function(self)<br>+ check_sequence_arg(self, 'reset')<br>+<br> return internal.sequence.reset(self.id)<br> end<br> <br> sequence_mt.alter = function(self, opts)<br>+ check_sequence_arg(self, 'alter')<br>+<br> box.schema.sequence.alter(self.id, opts)<br> end<br> <br> sequence_mt.drop = function(self)<br>+ check_sequence_arg(self, 'drop')<br>+<br> box.schema.sequence.drop(self.id)<br> end<br> <br>diff --git a/test/box/sequence.result b/test/box/sequence.result<br>index eb1d80d1b..17cdd8021 100644<br>--- a/test/box/sequence.result<br>+++ b/test/box/sequence.result<br>@@ -2379,3 +2379,33 @@ sq:current()<br> sq:drop()<br> ---<br> ...<br>+--<br>+-- gh-4754: throw error similar to space.method() error<br>+-- Ex: 'Use sequence:next(...) instead of sequence.next(...)'<br>+--<br>+sq = box.schema.sequence.create('test')<br>+---<br>+...<br>+sq.next()<br>+---<br>+- error: 'builtin/box/schema.lua:1816: Use sequence:next(...) instead of sequence.next(...)'<br>+...<br>+sq.current()<br>+---<br>+- error: 'builtin/box/schema.lua:1816: Use sequence:current(...) instead of sequence.current(...)'<br>+...<br>+sq.set()<br>+---<br>+- error: 'builtin/box/schema.lua:1816: Use sequence:set(...) instead of sequence.set(...)'<br>+...<br>+sq.reset()<br>+---<br>+- error: 'builtin/box/schema.lua:1816: Use sequence:reset(...) instead of sequence.reset(...)'<br>+...<br>+sq.drop()<br>+---<br>+- error: 'builtin/box/schema.lua:1816: Use sequence:drop(...) instead of sequence.drop(...)'<br>+...<br>+sq:drop()<br>+---<br>+...<br>\ No newline at end of file<br>diff --git a/test/box/sequence.test.lua b/test/box/sequence.test.lua<br>index a49565b8a..9ea61daef 100644<br>--- a/test/box/sequence.test.lua<br>+++ b/test/box/sequence.test.lua<br>@@ -812,3 +812,15 @@ sq:current()<br> sq:reset()<br> sq:current()<br> sq:drop()<br>+<br>+--<br>+-- gh-4754: throw error similar to space.method() error<br>+-- Ex: 'Use sequence:next(...) instead of sequence.next(...)'<br>+--<br>+sq = box.schema.sequence.create('test')<br>+sq.next()<br>+sq.current()<br>+sq.set()<br>+sq.reset()<br>+sq.drop()<br>+sq:drop()<br>\ No newline at end of file<br>-- <br>2.17.1<br> </div></div></div><style type="text/css"></style></BODY></HTML>