Skip to content

Commit

Permalink
Fix the == operator of Path (vesoft-inc#2524)
Browse files Browse the repository at this point in the history
* fix path equal

* minor

Co-authored-by: Cheng Xuntao <7731943+xtcyclist@users.noreply.github.com>
  • Loading branch information
nebula-bots and xtcyclist authored Mar 28, 2023
1 parent 96de609 commit b439922
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/common/datatypes/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ struct Step {
}

bool operator==(const Step& rhs) const {
return dst == rhs.dst && type == rhs.type && name == rhs.name && ranking == rhs.ranking &&
props == rhs.props;
return dst == rhs.dst && (type == rhs.type || type == -rhs.type) && name == rhs.name &&
ranking == rhs.ranking && props == rhs.props;
}

bool operator<(const Step& rhs) const {
if (dst != rhs.dst) {
return dst < rhs.dst;
}
if (type != rhs.type) {
return type < rhs.type;
if (type != rhs.type && type != -rhs.type) {
return abs(type) < abs(rhs.type);
}
if (ranking != rhs.ranking) {
return ranking < rhs.ranking;
Expand Down
14 changes: 14 additions & 0 deletions tests/tck/features/match/Path.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ Feature: Matching paths
Then the result should be, in any order:
| count(p) | count(p2) |
| 966 | 966 |
When executing query:
"""
match p = (v:Label_5)-[e:Rel_0]->(v1:Label_1),
p2 = (v)<-[e1:Rel_0]-(v1)
where id(v) == 47
and (p!=p2 or p<p2 or p>p2)
and e == e1
and v == v
and v1 == v1
return count(*)
"""
Then the result should be, in any order:
| count(*) |
| 0 |

# The correctness of the following test cases needs to be verified, mark it @skip for now
@skip
Expand Down

0 comments on commit b439922

Please sign in to comment.