diff --git a/src/graph/test/SchemaTest.cpp b/src/graph/test/SchemaTest.cpp index 671365d0a19..41096d3b413 100644 --- a/src/graph/test/SchemaTest.cpp +++ b/src/graph/test/SchemaTest.cpp @@ -1090,5 +1090,34 @@ TEST_F(SchemaTest, TestTagAndEdge) { LOG(FATAL) << "Space still exists after sleep " << retry << " seconds"; } +TEST_F(SchemaTest, issue2009) { + auto client = gEnv->getClient(); + ASSERT_NE(nullptr, client); + { + cpp2::ExecutionResponse resp; + std::string query = "CREATE SPACE issue2009; USE issue2009"; + auto code = client->execute(query, resp); + ASSERT_EQ(code, cpp2::ErrorCode::SUCCEEDED); + } + { + cpp2::ExecutionResponse resp; + std::string query = "CREATE EDGE IF NOT EXISTS relation" + "(intimacy int default 0, " + "isReversible bool default false, " + "name string default \"N/A\", " + "startTime timestamp default 0)"; + auto code = client->execute(query, resp); + ASSERT_EQ(code, cpp2::ErrorCode::SUCCEEDED); + } + ::sleep(FLAGS_heartbeat_interval_secs + 1); + { + cpp2::ExecutionResponse resp; + std::string query = "INSERT EDGE relation (intimacy) VALUES " + "hash(\"person.Tom\") -> hash(\"person.Marry\")@0:(3)"; + auto code = client->execute(query, resp); + ASSERT_EQ(code, cpp2::ErrorCode::SUCCEEDED); + } +} + } // namespace graph } // namespace nebula diff --git a/src/meta/processors/schemaMan/CreateEdgeProcessor.cpp b/src/meta/processors/schemaMan/CreateEdgeProcessor.cpp index eefafbacf3d..3090f4e634c 100644 --- a/src/meta/processors/schemaMan/CreateEdgeProcessor.cpp +++ b/src/meta/processors/schemaMan/CreateEdgeProcessor.cpp @@ -102,8 +102,21 @@ void CreateEdgeProcessor::process(const cpp2::CreateEdgeReq& req) { } defaultValue = value->get_string_value(); break; - default: + case nebula::cpp2::SupportedType::TIMESTAMP: + if (value->getType() != nebula::cpp2::Value::Type::timestamp) { + LOG(ERROR) << "Create Edge Failed: " << name + << " type mismatch"; + handleErrorCode(cpp2::ErrorCode::E_CONFLICT); + onFinished(); + return; + } + defaultValue = folly::to(value->get_timestamp()); break; + default: + LOG(ERROR) << "Unknown type " << static_cast(column.get_type().get_type()); + handleErrorCode(cpp2::ErrorCode::E_INVALID_PARM); + onFinished(); + return; } VLOG(3) << "Get Edge Default value: Property Name " << name << ", Value " << defaultValue; diff --git a/src/meta/processors/schemaMan/CreateTagProcessor.cpp b/src/meta/processors/schemaMan/CreateTagProcessor.cpp index 4370af7bc2f..46fb5798c95 100644 --- a/src/meta/processors/schemaMan/CreateTagProcessor.cpp +++ b/src/meta/processors/schemaMan/CreateTagProcessor.cpp @@ -114,7 +114,9 @@ void CreateTagProcessor::process(const cpp2::CreateTagReq& req) { defaultValue = folly::to(value->get_timestamp()); break; default: - LOG(ERROR) << "Unsupported type"; + LOG(ERROR) << "Unknown type " << static_cast(column.get_type().get_type()); + handleErrorCode(cpp2::ErrorCode::E_INVALID_PARM); + onFinished(); return; }