Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here should be E_INVALID_PARM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep same with before.

onFinished();
return;
}
defaultValue = folly::to<std::string>(value->get_timestamp());
break;
default:
LOG(ERROR) << "Unkown type " << static_cast<int>(column.get_type().get_type());
Shylock-Hg marked this conversation as resolved.
Show resolved Hide resolved
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) << "Unkown type " << static_cast<int>(column.get_type().get_type());
Shylock-Hg marked this conversation as resolved.
Show resolved Hide resolved
handleErrorCode(cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}

Expand Down