From 3f9a73a7f40dc1e6ceaa968dadf3fd452e3f3016 Mon Sep 17 00:00:00 2001 From: Alexandr Lyapunov <aleks@tarantool.org> Date: Thu, 26 Oct 2017 17:08:32 +0300 Subject: [PATCH] Make collation by name lookup case insensitive test:create_index('unicode_s1', {parts = {{1, 'STR', collation = 'UNICODE'}}}) will work now. Fix #2862 part 3 --- src/box/lua/schema.lua | 3 +++ test/box/misc.result | 19 +++++++++++++++++++ test/box/misc.test.lua | 7 +++++++ test/engine/iterator.result | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 6db1c3f367..77241b831c 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -521,6 +521,9 @@ local function update_index_parts(space_id, parts) elseif k == 'collation' then -- find ID by name local coll = box.space._collation.index.name:get{v} + if not coll then + coll = box.space._collation.index.name:get{v:lower()} + end if not coll then box.error(box.error.ILLEGAL_PARAMS, "options.parts[" .. i .. "]: collation was not found by name '" .. v .. "'") diff --git a/test/box/misc.result b/test/box/misc.result index b202d493d7..5616c01ad9 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -1001,3 +1001,22 @@ test_run:grep_log("default", "password") --- - password ... +-- some collation test +s = box.schema.space.create('test') +--- +... +not not s:create_index('test1', {parts = {{1, 'string', collation = 'Unicode'}}}) +--- +- true +... +not not s:create_index('test2', {parts = {{2, 'string', collation = 'UNICODE'}}}) +--- +- true +... +not not s:create_index('test3', {parts = {{3, 'string', collation = 'UnIcOdE'}}}) -- I'd prefer to panic on that +--- +- true +... +s:drop() +--- +... diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua index 8dc8da8191..c3d515454a 100644 --- a/test/box/misc.test.lua +++ b/test/box/misc.test.lua @@ -272,3 +272,10 @@ test_run:cmd("clear filter") -- test test_run:grep_log() require('log').info('Incorrect password supplied') test_run:grep_log("default", "password") + +-- some collation test +s = box.schema.space.create('test') +not not s:create_index('test1', {parts = {{1, 'string', collation = 'Unicode'}}}) +not not s:create_index('test2', {parts = {{2, 'string', collation = 'UNICODE'}}}) +not not s:create_index('test3', {parts = {{3, 'string', collation = 'UnIcOdE'}}}) -- I'd prefer to panic on that +s:drop() diff --git a/test/engine/iterator.result b/test/engine/iterator.result index 29b2e332c6..58f2abce72 100644 --- a/test/engine/iterator.result +++ b/test/engine/iterator.result @@ -4211,7 +4211,7 @@ s:replace{35} ... state, value = gen(param,state) --- -- error: 'builtin/box/schema.lua:955: usage: next(param, state)' +- error: 'builtin/box/schema.lua:958: usage: next(param, state)' ... value --- -- GitLab