-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Subgraph Composition: Fix Entity Ordering with different Idtype #5760
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
Subgraph Composition: Fix Entity Ordering with different Idtype #5760
Conversation
| let other_str = String::from_utf8(other.id.clone()).map_err(IdCompareError::InvalidUtf8)?; | ||
| Ok(self_str.cmp(&other_str)) | ||
| } | ||
| IdType::Bytes => Ok(self.id.cmp(&other.id)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same check could be used for the string too. We don't care what is the content of the ID, only if it's equal to the other one. And I would go so far to say that it holds for Int8 case too as we don't mind if the order is ascending or descending, we only need the cmp() to be able to detect equality and have a consistent ordering otherwise which is achieved with byte comparison. So I would keep the Ord a it is and only change the type of the id field in EntityDataExt.
| } | ||
|
|
||
| #[test] | ||
| fn read_range_pool_created_test() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice to add a test case!
0d72898 to
ad34735
Compare
| fn compare_entity_data_ext(a: &EntityDataExt, b: &EntityDataExt) -> std::cmp::Ordering { | ||
| a.block_number | ||
| .cmp(&b.block_number) | ||
| .then_with(|| a.entity.cmp(&b.entity)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elegant!
ad34735 to
748ff48
Compare
14671db to
640e7d1
Compare
06edc2b to
f38680e
Compare
097a772 to
d8bea9d
Compare
3d25869 to
6a28007
Compare
197b18d to
2a45671
Compare
e5d997b to
c8d8103
Compare
2a45671 to
e28ab16
Compare
c8d8103 to
a6b7647
Compare
a6b7647 to
9fa915b
Compare
e28ab16 to
4a290bf
Compare
c82c6cf to
432ba56
Compare
No description provided.