From 25828698f947f70dd516df34185f08d942e1532d Mon Sep 17 00:00:00 2001 From: Borislav Demidov Date: Thu, 8 Jun 2023 21:41:31 +0300 Subject: [PATCH 1/2] test: add test for IsNullable Field flag --- config.lua | 3 ++- tarantool_test.go | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/config.lua b/config.lua index aafb98ceb..2553b94c8 100644 --- a/config.lua +++ b/config.lua @@ -16,7 +16,7 @@ box.once("init", function() id = 616, temporary = true, if_not_exists = true, - field_count = 7, + field_count = 8, format = { {name = "name0", type = "unsigned"}, {name = "name1", type = "unsigned"}, @@ -24,6 +24,7 @@ box.once("init", function() {name = "name3", type = "unsigned"}, {name = "name4", type = "unsigned"}, {name = "name5", type = "string"}, + {name = "nullable", is_nullable = true}, }, }) st:create_index('primary', { diff --git a/tarantool_test.go b/tarantool_test.go index 0d56b4ada..d58a6775f 100644 --- a/tarantool_test.go +++ b/tarantool_test.go @@ -1908,7 +1908,7 @@ func TestSchema(t *testing.T) { if space.Engine != "memtx" { t.Errorf("space 616 engine should be memtx") } - if space.FieldsCount != 7 { + if space.FieldsCount != 8 { t.Errorf("space 616 has incorrect fields count") } @@ -1918,10 +1918,10 @@ func TestSchema(t *testing.T) { if space.Fields == nil { t.Errorf("space.Fields is nill") } - if len(space.FieldsById) != 6 { + if len(space.FieldsById) != 7 { t.Errorf("space.FieldsById len is incorrect") } - if len(space.Fields) != 6 { + if len(space.Fields) != 7 { t.Errorf("space.Fields len is incorrect") } @@ -2045,6 +2045,39 @@ func TestSchema(t *testing.T) { } } +func TestSchema_IsNullable(t *testing.T) { + conn := test_helpers.ConnectWithValidation(t, server, opts) + defer conn.Close() + + schema := conn.Schema + if schema.Spaces == nil { + t.Errorf("schema.Spaces is nil") + } + + var space *Space + var ok bool + if space, ok = schema.SpacesById[616]; !ok { + t.Errorf("space with id = 616 was not found in schema.SpacesById") + } + + var field, field_nullable *Field + for i := 0; i <= 5; i++ { + name := fmt.Sprintf("name%d", i) + if field, ok = space.Fields[name]; !ok { + t.Errorf("field name = %s was not found", name) + } + if field.IsNullable { + t.Errorf("field %s has incorrect IsNullable", name) + } + } + if field_nullable, ok = space.Fields["nullable"]; !ok { + t.Errorf("field name = nullable was not found") + } + if !field_nullable.IsNullable { + t.Errorf("field nullable has incorrect IsNullable") + } +} + func TestClientNamed(t *testing.T) { var resp *Response var err error From be209ae81d154bd61b164eaf9b02b12392f93f1d Mon Sep 17 00:00:00 2001 From: Borislav Demidov Date: Thu, 8 Jun 2023 21:47:48 +0300 Subject: [PATCH 2/2] changelog: add message on IsNullable Field flag --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 759dc43c7..185ec2915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release. - Type() method to the Request interface (#158) - Enumeration types for RLimitAction/iterators (#158) +- IsNullable flag for Field (#302) ### Changed