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

Fix the == operator of Path #5444

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/common/datatypes/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ 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 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to fix operator< too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we compare dst == src when type is negative?

Copy link
Contributor Author

@xtcyclist xtcyclist Mar 28, 2023

Choose a reason for hiding this comment

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

I think it's not needed, assuming STEP itself is correctly constructed. This is comparing two STEPS, not EDGES, so only the dst need to be compared. There is also no src member in STEP.

This diff avoids treating two physical versions of the same self-reflective edges (constructed as STEPs here) as different.

ranking == rhs.ranking && props == rhs.props;
}

bool operator<(const Step& rhs) const {
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
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