Skip to content

Commit

Permalink
Correct issue 2009 which the timestamp default value for edge not tre…
Browse files Browse the repository at this point in the history
…at. (vesoft-inc#2038)

* Correct issue 2009 which the timestamp default value for edge not treat.

* Add the cover cases.

* Fix one typo.

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
(cherry picked from commit 4aa9217)
  • Loading branch information
Shylock-Hg authored and jude-zhu committed Apr 2, 2020
1 parent 213c484 commit 4df895a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/graph/test/SchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion src/meta/processors/schemaMan/CreateEdgeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(value->get_timestamp());
break;
default:
LOG(ERROR) << "Unknown type " << static_cast<int>(column.get_type().get_type());
handleErrorCode(cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}
VLOG(3) << "Get Edge Default value: Property Name " << name
<< ", Value " << defaultValue;
Expand Down
4 changes: 3 additions & 1 deletion src/meta/processors/schemaMan/CreateTagProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ void CreateTagProcessor::process(const cpp2::CreateTagReq& req) {
defaultValue = folly::to<std::string>(value->get_timestamp());
break;
default:
LOG(ERROR) << "Unsupported type";
LOG(ERROR) << "Unknown type " << static_cast<int>(column.get_type().get_type());
handleErrorCode(cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}

Expand Down

0 comments on commit 4df895a

Please sign in to comment.