Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] net.box: fix 'unique' index flag in net.box schema
@ 2019-04-01  5:08 Alexander Turenko
  2019-04-01  8:42 ` [tarantool-patches] " Vladislav Shpilevoy
  2019-04-12 16:22 ` Kirill Yukhin
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Turenko @ 2019-04-01  5:08 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: Alexander Turenko, tarantool-patches

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-12 16:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-01  5:08 [tarantool-patches] [PATCH] net.box: fix 'unique' index flag in net.box schema Alexander Turenko
2019-04-01  8:42 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-01 10:08   ` Alexander Turenko
2019-04-01 15:32     ` Vladislav Shpilevoy
2019-04-01 16:15       ` Alexander Turenko
2019-04-01 17:51         ` Vladislav Shpilevoy
2019-04-12 16:22 ` Kirill Yukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox