Skip to content

Commit

Permalink
Fix GetNeighborsIter::getEdge crash when no edge schema in space (#2571)
Browse files Browse the repository at this point in the history
migrate from vesoft-inc/nebula-graph#1313

Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com>
  • Loading branch information
jievince and yixinglu committed Aug 26, 2021
1 parent dc2edaa commit e127d63
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ cmake-build*/
.cache/
core.*
workspace.*
.metals/

#py
*.egg-info
Expand Down
8 changes: 8 additions & 0 deletions src/graph/context/Iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ const Value& GetNeighborsIter::getEdgeProp(const std::string& edge, const std::s
return Value::kNullValue;
}

if (noEdge_) {
return Value::kEmpty;
}

auto& currentEdge = currentEdgeName();
if (edge != "*" && (currentEdge.compare(1, std::string::npos, edge) != 0)) {
VLOG(1) << "Current edge: " << currentEdgeName() << " Wanted: " << edge;
Expand Down Expand Up @@ -383,6 +387,10 @@ Value GetNeighborsIter::getEdge() const {
return Value::kNullValue;
}

if (noEdge_) {
return Value::kEmpty;
}

Edge edge;
auto edgeName = currentEdgeName().substr(1, std::string::npos);
edge.name = edgeName;
Expand Down
22 changes: 22 additions & 0 deletions tests/tck/features/match/Base.feature
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,28 @@ Feature: Basic match
| p |
| <("LeBron James")-[:like@0]->("Ray Allen")-[:like@0]->("Rajon Rondo")> |

Scenario: Match a path in a space which doesn't have edge schema
Given an empty graph
And create a space with following options:
| partition_num | 9 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(20) |
And having executed:
"""
CREATE TAG IF NOT EXISTS person(name string);
"""
When try to execute query:
"""
INSERT VERTEX person VALUES "Tom":("Tom")
"""
Then the execution should be successful
When executing query:
"""
MATCH p=(v)-[e*1]->(v2) WHERE id(v) IN ["Tom"] RETURN p
"""
Then the result should be, in any order, with relax comparison:
| p |

Scenario: Unsupported combination of some cypher clauses
When executing query:
"""
Expand Down
24 changes: 24 additions & 0 deletions tests/tck/features/subgraph/subgraph.feature
Original file line number Diff line number Diff line change
Expand Up @@ -894,3 +894,27 @@ Feature: subgraph
| <[vertex3]> | <[edge3]> |
| <[vertex4]> | <[edge4]> |
| <[vertex5]> | [] |

Scenario: Get subgraph in a space which doesn't have edge schema
Given an empty graph
And create a space with following options:
| partition_num | 9 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(20) |
And having executed:
"""
CREATE TAG IF NOT EXISTS person(name string);
"""
When try to execute query:
"""
INSERT VERTEX person VALUES "Tom":("Tom")
"""
Then the execution should be successful
When executing query:
"""
GET SUBGRAPH 1 STEPS FROM "Tom"
"""
Then the result should be, in any order, with relax comparison:
| _vertices | _edges |
| [("Tom")] | [] |
| [] | [] |

0 comments on commit e127d63

Please sign in to comment.