From 394bd785ed60f7688115babf1032ffcb51404f0d Mon Sep 17 00:00:00 2001 From: CBS <56461666+bright-starry-sky@users.noreply.github.com> Date: Mon, 11 Oct 2021 09:46:43 +0800 Subject: [PATCH] fixed bug for index scan when index column is not nullable. (#3012) * fixed nullable error * tck fmt --- src/storage/index/LookupBaseProcessor-inl.h | 2 +- tests/tck/features/insert/Insert.feature | 23 ++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/storage/index/LookupBaseProcessor-inl.h b/src/storage/index/LookupBaseProcessor-inl.h index 54a91539b0d..5fb46d38a83 100644 --- a/src/storage/index/LookupBaseProcessor-inl.h +++ b/src/storage/index/LookupBaseProcessor-inl.h @@ -196,7 +196,7 @@ StatusOr> LookupBaseProcessor::buildPlan( auto fields = indexItem->get_fields(); for (const auto& col : fields) { - if (!hasNullableCol && col.get_nullable()) { + if (!hasNullableCol && col.nullable_ref().value_or(false)) { hasNullableCol = true; break; } diff --git a/tests/tck/features/insert/Insert.feature b/tests/tck/features/insert/Insert.feature index bf93863d498..feaa9ecbf8b 100644 --- a/tests/tck/features/insert/Insert.feature +++ b/tests/tck/features/insert/Insert.feature @@ -466,6 +466,8 @@ Feature: Insert string vid of vertex and edge """ CREATE TAG student(name string NOT NULL, age int); CREATE TAG course(name fixed_string(5) NOT NULL, introduce string DEFAULT NULL); + CREATE TAG INDEX student_i ON student(name(30), age); + CREATE TAG INDEX course_i ON course(name, introduce(30)); """ # test insert with fixed_string When try to execute query: @@ -491,11 +493,6 @@ Feature: Insert string vid of vertex and edge INSERT VERTEX student(name, age) VALUES "Tom":(NULL, 12) """ Then a ExecutionError should be raised at runtime: Storage Error: The not null field cannot be null. - When executing query: - """ - INSERT VERTEX student(name, age) VALUES "Tom":(NULL, 12) - """ - Then a ExecutionError should be raised at runtime: Storage Error: The not null field cannot be null. # out of fixed_string's size When executing query: """ @@ -518,4 +515,20 @@ Feature: Insert string vid of vertex and edge Then the result should be, in any order: | VertexID | student.name | student.age | | '' | 'Tom' | 12 | + # check result + When executing query: + """ + LOOKUP on course YIELD course.name, course.introduce + """ + Then the result should be, in any order: + | VertexID | course.name | course.introduce | + | 'English' | 'Engli' | NULL | + | 'Math' | 'Math' | NULL | + When executing query: + """ + LOOKUP ON student YIELD student.name, student.age + """ + Then the result should be, in any order: + | VertexID | student.name | student.age | + | '' | 'Tom' | 12 | Then drop the used space