From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4235929485 for ; Mon, 1 Apr 2019 01:09:08 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sd25yUQxt9lX for ; Mon, 1 Apr 2019 01:09:08 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 8DFE628BF5 for ; Mon, 1 Apr 2019 01:09:07 -0400 (EDT) From: Alexander Turenko Subject: [tarantool-patches] [PATCH] net.box: fix 'unique' index flag in net.box schema Date: Mon, 1 Apr 2019 08:08:58 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: Vladislav Shpilevoy Cc: Alexander Turenko , tarantool-patches@freelists.org Before this commit it always returns false. Fixes #4091. --- https://github.com/tarantool/tarantool/issues/4091 https://github.com/tarantool/tarantool/tree/Totktonada/gh-4091-net.box-indexes-are-always-non-unique src/box/lua/net_box.lua | 2 +- ...box-indexes-are-always-non-unique.test.lua | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 test/box-tap/gh-4091-net.box-indexes-are-always-non-unique.test.lua diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua index b3139a3f5..e1c4b652b 100644 --- a/src/box/lua/net_box.lua +++ b/src/box/lua/net_box.lua @@ -1253,7 +1253,7 @@ function remote_methods:_install_schema(schema_version, spaces, indices) } idx.parts[k] = pk end - idx.unique = not not index[OPTS].is_unique + idx.unique = not not index[OPTS].unique end if sl[idx.space] ~= nil then diff --git a/test/box-tap/gh-4091-net.box-indexes-are-always-non-unique.test.lua b/test/box-tap/gh-4091-net.box-indexes-are-always-non-unique.test.lua new file mode 100755 index 000000000..04c576915 --- /dev/null +++ b/test/box-tap/gh-4091-net.box-indexes-are-always-non-unique.test.lua @@ -0,0 +1,30 @@ +#!/usr/bin/env tarantool + +local tap = require('tap') +local net_box = require('net.box') +local urilib = require('uri') + +box.cfg({ + listen = os.getenv('LISTEN') or 'localhost:3301', +}) + +box.schema.user.grant('guest', 'read,write,execute', 'universe') + +box.schema.create_space('s') +box.space.s:create_index('pk') +box.space.s:create_index('sk', {unique = false}) + +local test = tap.test('gh-4091-net.box-indexes-are-always-non-unique') +test:plan(2) + +local uri = urilib.parse(box.cfg.listen) +local uri = ('%s:%s'):format(uri.host or 'localhost', uri.service) +local conn = net_box.connect(uri) + +test:is(conn.space.s.index.pk.unique, true, 'unique index') +test:is(conn.space.s.index.sk.unique, false, 'non-unique index') + +box.space.s:drop() +box.schema.user.revoke('guest', 'read,write,execute', 'universe') + +os.exit(test:check() == true and 0 or 1) -- 2.20.1