Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit daab888

Browse files
laura-dingdutor
andauthored
Fix show create ttl_col (vesoft-inc#2373)
Co-authored-by: dutor <[email protected]>
1 parent 65a9cc3 commit daab888

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/graph/ShowExecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ void ShowExecutor::showCreateTag() {
671671
}
672672
buf += ", ttl_col = ";
673673
if (prop.get_ttl_col() && !(prop.get_ttl_col()->empty())) {
674-
buf += *prop.get_ttl_col();
674+
buf += "\"" + *prop.get_ttl_col() + "\"";
675675
} else {
676676
buf += "\"\"";
677677
}
@@ -774,7 +774,7 @@ void ShowExecutor::showCreateEdge() {
774774
}
775775
buf += ", ttl_col = ";
776776
if (prop.get_ttl_col() && !(prop.get_ttl_col()->empty())) {
777-
buf += *prop.get_ttl_col();
777+
buf += "\"" + *prop.get_ttl_col() + "\"";
778778
} else {
779779
buf += "\"\"";
780780
}

src/graph/test/TTLTest.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ TEST_F(TTLTest, schematest) {
115115
" `age` int,\n"
116116
" `gender` string,\n"
117117
" `row_timestamp` timestamp\n"
118-
") ttl_duration = 100, ttl_col = row_timestamp";
118+
") ttl_duration = 100, ttl_col = \"row_timestamp\"";
119119
std::vector<uniform_tuple_t<std::string, 2>> expected{
120120
{"man", createTagStr},
121121
};
@@ -160,7 +160,7 @@ TEST_F(TTLTest, schematest) {
160160
" `age` int,\n"
161161
" `gender` string,\n"
162162
" `row_timestamp` timestamp\n"
163-
") ttl_duration = 0, ttl_col = row_timestamp";
163+
") ttl_duration = 0, ttl_col = \"row_timestamp\"";
164164
std::vector<uniform_tuple_t<std::string, 2>> expected{
165165
{"woman", createTagStr},
166166
};
@@ -186,7 +186,7 @@ TEST_F(TTLTest, schematest) {
186186
" `age` int,\n"
187187
" `gender` string,\n"
188188
" `row_timestamp` timestamp\n"
189-
") ttl_duration = 0, ttl_col = row_timestamp";
189+
") ttl_duration = 0, ttl_col = \"row_timestamp\"";
190190
std::vector<uniform_tuple_t<std::string, 2>> expected{
191191
{"only_ttl_col", createTagStr},
192192
};
@@ -210,7 +210,7 @@ TEST_F(TTLTest, schematest) {
210210
" `age` int,\n"
211211
" `gender` string,\n"
212212
" `row_timestamp` timestamp\n"
213-
") ttl_duration = 50, ttl_col = row_timestamp";
213+
") ttl_duration = 50, ttl_col = \"row_timestamp\"";
214214
std::vector<uniform_tuple_t<std::string, 2>> expected{
215215
{"woman", createTagStr},
216216
};
@@ -241,11 +241,16 @@ TEST_F(TTLTest, schematest) {
241241
" `age` int,\n"
242242
" `gender` string,\n"
243243
" `row_timestamp` timestamp\n"
244-
") ttl_duration = 200, ttl_col = row_timestamp";
244+
") ttl_duration = 200, ttl_col = \"row_timestamp\"";
245245
std::vector<uniform_tuple_t<std::string, 2>> expected{
246246
{"woman", createTagStr},
247247
};
248248
ASSERT_TRUE(verifyResult(resp, expected));
249+
250+
// check the createTagStr can be execute
251+
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, client->execute("DROP TAG woman", resp));
252+
253+
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, client->execute(createTagStr, resp));
249254
}
250255
// When the column is as TTL column, droping column
251256
{
@@ -288,7 +293,7 @@ TEST_F(TTLTest, schematest) {
288293
" `email` string,\n"
289294
" `age` int,\n"
290295
" `gender` string\n"
291-
") ttl_duration = 100, ttl_col = age";
296+
") ttl_duration = 100, ttl_col = \"age\"";
292297
std::vector<uniform_tuple_t<std::string, 2>> expected{
293298
{"woman", createTagStr},
294299
};
@@ -399,11 +404,16 @@ TEST_F(TTLTest, schematest) {
399404
" `age` int,\n"
400405
" `gender` string,\n"
401406
" `row_timestamp` timestamp\n"
402-
") ttl_duration = 100, ttl_col = row_timestamp";
407+
") ttl_duration = 100, ttl_col = \"row_timestamp\"";
403408
std::vector<uniform_tuple_t<std::string, 2>> expected{
404409
{"work1", createEdgeStr},
405410
};
406411
ASSERT_TRUE(verifyResult(resp, expected));
412+
413+
// check the createEdgeStr can be execute
414+
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, client->execute("DROP EDGE work1", resp));
415+
416+
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, client->execute(createEdgeStr, resp));
407417
}
408418

409419
// Disable implicit ttl mode
@@ -442,7 +452,7 @@ TEST_F(TTLTest, schematest) {
442452
" `age` int,\n"
443453
" `gender` string,\n"
444454
" `start_time` timestamp\n"
445-
") ttl_duration = 0, ttl_col = start_time";
455+
") ttl_duration = 0, ttl_col = \"start_time\"";
446456
std::vector<uniform_tuple_t<std::string, 2>> expected{
447457
{"work2", createEdgeStr},
448458
};
@@ -468,7 +478,7 @@ TEST_F(TTLTest, schematest) {
468478
" `age` int,\n"
469479
" `gender` string,\n"
470480
" `row_timestamp` timestamp\n"
471-
") ttl_duration = 0, ttl_col = row_timestamp";
481+
") ttl_duration = 0, ttl_col = \"row_timestamp\"";
472482
std::vector<uniform_tuple_t<std::string, 2>> expected{
473483
{"edge_only_ttl_col", createEdgeStr},
474484
};
@@ -493,7 +503,7 @@ TEST_F(TTLTest, schematest) {
493503
" `age` int,\n"
494504
" `gender` string,\n"
495505
" `start_time` timestamp\n"
496-
") ttl_duration = 50, ttl_col = start_time";
506+
") ttl_duration = 50, ttl_col = \"start_time\"";
497507
std::vector<uniform_tuple_t<std::string, 2>> expected{
498508
{"work2", createEdgeStr},
499509
};
@@ -524,7 +534,7 @@ TEST_F(TTLTest, schematest) {
524534
" `age` int,\n"
525535
" `gender` string,\n"
526536
" `start_time` timestamp\n"
527-
") ttl_duration = 200, ttl_col = start_time";
537+
") ttl_duration = 200, ttl_col = \"start_time\"";
528538
std::vector<uniform_tuple_t<std::string, 2>> expected{
529539
{"work2", createEdgeStr},
530540
};
@@ -570,7 +580,7 @@ TEST_F(TTLTest, schematest) {
570580
" `email` string,\n"
571581
" `age` int,\n"
572582
" `gender` string\n"
573-
") ttl_duration = 100, ttl_col = age";
583+
") ttl_duration = 100, ttl_col = \"age\"";
574584
std::vector<uniform_tuple_t<std::string, 2>> expected{
575585
{"work2", createTagStr},
576586
};
@@ -1124,3 +1134,4 @@ TEST_F(TTLTest, Datatest) {
11241134

11251135
} // namespace graph
11261136
} // namespace nebula
1137+

0 commit comments

Comments
 (0)