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

Skip to content

Commit 611c670

Browse files
pengweisongjievinceSophie-Xie
authored
fix folly::stringPrintf when ref empty str (vesoft-inc#4933)
* fix folly::stringPrintf when ref empty str * remove static cast * fix udpate test * add an tck and some usage * fix grammer Co-authored-by: jie.wang <[email protected]> Co-authored-by: Sophie <[email protected]>
1 parent f485455 commit 611c670

File tree

4 files changed

+54
-43
lines changed

4 files changed

+54
-43
lines changed

src/storage/exec/UpdateResultNode.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ class UpdateResNode : public RelNode<T> {
6262
std::vector<Value> row;
6363
row.emplace_back(insert_);
6464

65-
for (auto& retExp : returnPropsExp_) {
66-
auto exp = static_cast<PropertyExpression*>(retExp);
65+
for (auto& exp : returnPropsExp_) {
6766
auto& val = exp->eval(*expCtx_);
6867
if (exp) {
69-
result_->colNames.emplace_back(
70-
folly::stringPrintf("%s.%s", exp->sym().c_str(), exp->prop().c_str()));
68+
result_->colNames.emplace_back(exp->toString());
7169
} else {
7270
VLOG(1) << "Can't get expression name";
7371
result_->colNames.emplace_back("NULL");

src/storage/test/UpdateVertexTest.cpp

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ TEST(UpdateVertexTest, No_Filter_Test) {
167167
EXPECT_EQ(0, (*resp.result_ref()).failed_parts.size());
168168
EXPECT_EQ(6, (*resp.props_ref()).colNames.size());
169169
EXPECT_EQ("_inserted", (*resp.props_ref()).colNames[0]);
170-
EXPECT_EQ("1.name", (*resp.props_ref()).colNames[1]);
171-
EXPECT_EQ("1.age", (*resp.props_ref()).colNames[2]);
172-
EXPECT_EQ("1.country", (*resp.props_ref()).colNames[3]);
173-
EXPECT_EQ(std::string("1.").append(kVid), (*resp.props_ref()).colNames[4]);
174-
EXPECT_EQ(std::string("1.").append(kTag), (*resp.props_ref()).colNames[5]);
170+
EXPECT_EQ("$^.1.name", (*resp.props_ref()).colNames[1]);
171+
EXPECT_EQ("$^.1.age", (*resp.props_ref()).colNames[2]);
172+
EXPECT_EQ("$^.1.country", (*resp.props_ref()).colNames[3]);
173+
EXPECT_EQ(std::string("$^.1.").append(kVid), (*resp.props_ref()).colNames[4]);
174+
EXPECT_EQ(std::string("$^.1.").append(kTag), (*resp.props_ref()).colNames[5]);
175175

176176
EXPECT_EQ(1, (*resp.props_ref()).rows.size());
177177
EXPECT_EQ(6, (*resp.props_ref()).rows[0].values.size());
@@ -286,11 +286,11 @@ TEST(UpdateVertexTest, Filter_Yield_Test2) {
286286
// Note: If filtered out, the result is old
287287
EXPECT_EQ(6, (*resp.props_ref()).colNames.size());
288288
EXPECT_EQ("_inserted", (*resp.props_ref()).colNames[0]);
289-
EXPECT_EQ("1.name", (*resp.props_ref()).colNames[1]);
290-
EXPECT_EQ("1.age", (*resp.props_ref()).colNames[2]);
291-
EXPECT_EQ("1.country", (*resp.props_ref()).colNames[3]);
292-
EXPECT_EQ(std::string("1.").append(kVid), (*resp.props_ref()).colNames[4]);
293-
EXPECT_EQ(std::string("1.").append(kTag), (*resp.props_ref()).colNames[5]);
289+
EXPECT_EQ("$^.1.name", (*resp.props_ref()).colNames[1]);
290+
EXPECT_EQ("$^.1.age", (*resp.props_ref()).colNames[2]);
291+
EXPECT_EQ("$^.1.country", (*resp.props_ref()).colNames[3]);
292+
EXPECT_EQ(std::string("$^.1.").append(kVid), (*resp.props_ref()).colNames[4]);
293+
EXPECT_EQ(std::string("$^.1.").append(kTag), (*resp.props_ref()).colNames[5]);
294294

295295
EXPECT_EQ(1, (*resp.props_ref()).rows.size());
296296
EXPECT_EQ(6, (*resp.props_ref()).rows[0].values.size());
@@ -390,11 +390,11 @@ TEST(UpdateVertexTest, Insertable_Test) {
390390
EXPECT_EQ(0, (*resp.result_ref()).failed_parts.size());
391391
EXPECT_EQ(6, (*resp.props_ref()).colNames.size());
392392
EXPECT_EQ("_inserted", (*resp.props_ref()).colNames[0]);
393-
EXPECT_EQ("1.name", (*resp.props_ref()).colNames[1]);
394-
EXPECT_EQ("1.age", (*resp.props_ref()).colNames[2]);
395-
EXPECT_EQ("1.country", (*resp.props_ref()).colNames[3]);
396-
EXPECT_EQ(std::string("1.").append(kVid), (*resp.props_ref()).colNames[4]);
397-
EXPECT_EQ(std::string("1.").append(kTag), (*resp.props_ref()).colNames[5]);
393+
EXPECT_EQ("$^.1.name", (*resp.props_ref()).colNames[1]);
394+
EXPECT_EQ("$^.1.age", (*resp.props_ref()).colNames[2]);
395+
EXPECT_EQ("$^.1.country", (*resp.props_ref()).colNames[3]);
396+
EXPECT_EQ(std::string("$^.1.").append(kVid), (*resp.props_ref()).colNames[4]);
397+
EXPECT_EQ(std::string("$^.1.").append(kTag), (*resp.props_ref()).colNames[5]);
398398

399399
EXPECT_EQ(1, (*resp.props_ref()).rows.size());
400400
EXPECT_EQ(6, (*resp.props_ref()).rows[0].values.size());
@@ -689,11 +689,11 @@ TEST(UpdateVertexTest, Insertable_Filter_Value_Test) {
689689
EXPECT_EQ(0, (*resp.result_ref()).failed_parts.size());
690690
EXPECT_EQ(6, (*resp.props_ref()).colNames.size());
691691
EXPECT_EQ("_inserted", (*resp.props_ref()).colNames[0]);
692-
EXPECT_EQ("1.name", (*resp.props_ref()).colNames[1]);
693-
EXPECT_EQ("1.age", (*resp.props_ref()).colNames[2]);
694-
EXPECT_EQ("1.country", (*resp.props_ref()).colNames[3]);
695-
EXPECT_EQ(std::string("1.").append(kVid), (*resp.props_ref()).colNames[4]);
696-
EXPECT_EQ(std::string("1.").append(kTag), (*resp.props_ref()).colNames[5]);
692+
EXPECT_EQ("$^.1.name", (*resp.props_ref()).colNames[1]);
693+
EXPECT_EQ("$^.1.age", (*resp.props_ref()).colNames[2]);
694+
EXPECT_EQ("$^.1.country", (*resp.props_ref()).colNames[3]);
695+
EXPECT_EQ(std::string("$^.1.").append(kVid), (*resp.props_ref()).colNames[4]);
696+
EXPECT_EQ(std::string("$^.1.").append(kTag), (*resp.props_ref()).colNames[5]);
697697

698698
EXPECT_EQ(1, (*resp.props_ref()).rows.size());
699699
EXPECT_EQ(true, (*resp.props_ref()).rows[0].values[0].getBool());
@@ -937,11 +937,11 @@ TEST(UpdateVertexTest, TTL_Insert_No_Exist_Test) {
937937
EXPECT_EQ(0, (*resp.result_ref()).failed_parts.size());
938938
EXPECT_EQ(6, (*resp.props_ref()).colNames.size());
939939
EXPECT_EQ("_inserted", (*resp.props_ref()).colNames[0]);
940-
EXPECT_EQ("1.name", (*resp.props_ref()).colNames[1]);
941-
EXPECT_EQ("1.age", (*resp.props_ref()).colNames[2]);
942-
EXPECT_EQ("1.country", (*resp.props_ref()).colNames[3]);
943-
EXPECT_EQ(std::string("1.").append(kVid), (*resp.props_ref()).colNames[4]);
944-
EXPECT_EQ(std::string("1.").append(kTag), (*resp.props_ref()).colNames[5]);
940+
EXPECT_EQ("$^.1.name", (*resp.props_ref()).colNames[1]);
941+
EXPECT_EQ("$^.1.age", (*resp.props_ref()).colNames[2]);
942+
EXPECT_EQ("$^.1.country", (*resp.props_ref()).colNames[3]);
943+
EXPECT_EQ(std::string("$^.1.").append(kVid), (*resp.props_ref()).colNames[4]);
944+
EXPECT_EQ(std::string("$^.1.").append(kTag), (*resp.props_ref()).colNames[5]);
945945

946946
EXPECT_EQ(1, (*resp.props_ref()).rows.size());
947947
EXPECT_EQ(6, (*resp.props_ref()).rows[0].values.size());
@@ -1056,11 +1056,11 @@ TEST(UpdateVertexTest, TTL_Insert_Test) {
10561056
EXPECT_EQ(0, (*resp.result_ref()).failed_parts.size());
10571057
EXPECT_EQ(6, (*resp.props_ref()).colNames.size());
10581058
EXPECT_EQ("_inserted", (*resp.props_ref()).colNames[0]);
1059-
EXPECT_EQ("1.name", (*resp.props_ref()).colNames[1]);
1060-
EXPECT_EQ("1.age", (*resp.props_ref()).colNames[2]);
1061-
EXPECT_EQ("1.country", (*resp.props_ref()).colNames[3]);
1062-
EXPECT_EQ(std::string("1.").append(kVid), (*resp.props_ref()).colNames[4]);
1063-
EXPECT_EQ(std::string("1.").append(kTag), (*resp.props_ref()).colNames[5]);
1059+
EXPECT_EQ("$^.1.name", (*resp.props_ref()).colNames[1]);
1060+
EXPECT_EQ("$^.1.age", (*resp.props_ref()).colNames[2]);
1061+
EXPECT_EQ("$^.1.country", (*resp.props_ref()).colNames[3]);
1062+
EXPECT_EQ(std::string("$^.1.").append(kVid), (*resp.props_ref()).colNames[4]);
1063+
EXPECT_EQ(std::string("$^.1.").append(kTag), (*resp.props_ref()).colNames[5]);
10641064

10651065
EXPECT_EQ(1, (*resp.props_ref()).rows.size());
10661066
EXPECT_EQ(6, (*resp.props_ref()).rows[0].values.size());
@@ -1242,10 +1242,10 @@ TEST(UpdateVertexTest, Insertable_In_Set_Test) {
12421242
EXPECT_EQ(0, (*resp.result_ref()).failed_parts.size());
12431243
EXPECT_EQ(5, (*resp.props_ref()).colNames.size());
12441244
EXPECT_EQ("_inserted", (*resp.props_ref()).colNames[0]);
1245-
EXPECT_EQ("1.name", (*resp.props_ref()).colNames[1]);
1246-
EXPECT_EQ("1.age", (*resp.props_ref()).colNames[2]);
1247-
EXPECT_EQ(std::string("1.").append(kVid), (*resp.props_ref()).colNames[3]);
1248-
EXPECT_EQ(std::string("1.").append(kTag), (*resp.props_ref()).colNames[4]);
1245+
EXPECT_EQ("$^.1.name", (*resp.props_ref()).colNames[1]);
1246+
EXPECT_EQ("$^.1.age", (*resp.props_ref()).colNames[2]);
1247+
EXPECT_EQ(std::string("$^.1.").append(kVid), (*resp.props_ref()).colNames[3]);
1248+
EXPECT_EQ(std::string("$^.1.").append(kTag), (*resp.props_ref()).colNames[4]);
12491249

12501250
EXPECT_EQ(1, (*resp.props_ref()).rows.size());
12511251
EXPECT_EQ(5, (*resp.props_ref()).rows[0].values.size());

tests/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Nebula Test framework depends on python3(>=3.7) and some thirdparty libraries, s
1313
So you should install all these dependencies before running test cases by:
1414

1515
```shell
16+
$ cd tests
1617
$ make init-all
1718
```
1819

@@ -51,6 +52,9 @@ $ make RM_DIR=false tck # default value of RM_DIR is true
5152
And if you want to debug only one test case, you should check the usage of `pytest` itself by `pytest --help`. For example, run the test cases related to `MATCH`, you can do it like:
5253

5354
```shell
55+
# pytest will use keyword 'match' to match the Scenario name. All the Scenario whose name contains
56+
# the keyword 'match' will be selected.
57+
# You can also use '@keyword' to annotate a scenario and using `pytest -k 'keyword'` to run only the one scenario.
5458
$ pytest -k 'match' -m 'not skip' .
5559
```
5660

tests/tck/features/update/Update.feature

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Feature: Update string vid of vertex and edge
66
Background: Prepare space
77
Given an empty graph
88
And create a space with following options:
9-
| partition_num | 1 |
10-
| replica_factor | 1 |
11-
| vid_type | FIXED_STRING(20) |
9+
| partition_num | 1 |
10+
| replica_factor | 1 |
11+
| vid_type | FIXED_STRING(200) |
1212
And having executed:
1313
"""
1414
CREATE TAG IF NOT EXISTS course(name string, credits int);
@@ -727,6 +727,15 @@ Feature: Update string vid of vertex and edge
727727
Then the result should be, in any order:
728728
| Name | Credits |
729729
| 'Math' | 6 |
730+
When executing query:
731+
"""
732+
UPDATE VERTEX ON course "101"
733+
SET credits = credits + 1
734+
YIELD "101" AS courseId, credits AS Credits
735+
"""
736+
Then the result should be, in any order:
737+
| courseId | Credits |
738+
| '101' | 7 |
730739
When executing query:
731740
"""
732741
UPDATE VERTEX ON course "101"
@@ -736,7 +745,7 @@ Feature: Update string vid of vertex and edge
736745
"""
737746
Then the result should be, in any order:
738747
| Name | Credits |
739-
| 'Math' | 7 |
748+
| 'Math' | 8 |
740749
When executing query:
741750
"""
742751
UPDATE VERTEX ON course "101"
@@ -746,7 +755,7 @@ Feature: Update string vid of vertex and edge
746755
"""
747756
Then the result should be, in any order:
748757
| Name | Credits |
749-
| 'Math' | 7 |
758+
| 'Math' | 8 |
750759
When executing query:
751760
"""
752761
FETCH PROP ON select "200"->"101"@0 YIELD select.grade, select.year

0 commit comments

Comments
 (0)