Skip to content

Compare IP adresses properly#172

Merged
suharev7 merged 1 commit intosuharev7:async-awaitfrom
scrabsha:scrabsha/compare-ip-addresses
May 15, 2022
Merged

Compare IP adresses properly#172
suharev7 merged 1 commit intosuharev7:async-awaitfrom
scrabsha:scrabsha/compare-ip-addresses

Conversation

@scrabsha
Copy link
Contributor

@scrabsha scrabsha commented May 14, 2022

Compare IP adresses and UUID properly

The implementation of PartialEq for Value is handcrafted. It is
composed of a huge match expression, which aims to properly compare
each variant of the left-hand and the right-hand Values. The last arm
is a catchall arm, supposed to catch every case where both variant does
not match.

The problem is that no match arm in the said expression handles the
Ipv4, Ipv6 and Uuid variants. As such, two IP addresses are always
considered as not equal. Similarly, two UUIDs are always considered as
not equal.

This commit adds three missing arms, which adds proper IP address
comparison as well as proper UUID comparison.

The implementation of `PartialEq` for `Value` is handcrafted. It is
composed of a huge `match` expression, which aims to properly compare
each variant of the left-hand and the right-hand `Values`. The last arm
is a catchall arm, supposed to catch every case where both variant does
not match.

The problem is that no match arm in the said expression handles the
`Ipv4`, `Ipv6` and `Uuid` variants. As such, two IP addresses are always
considered as not equal. Similarly, two UUIDs are always considered as
not equal.

This commit adds three missing arms, which adds proper IP address
comparison as well as proper UUID comparison.
@scrabsha scrabsha force-pushed the scrabsha/compare-ip-addresses branch from 53d5801 to 2ade71f Compare May 14, 2022 14:51
@suharev7 suharev7 merged commit eff0c76 into suharev7:async-await May 15, 2022
@suharev7
Copy link
Owner

Thank you

@scrabsha scrabsha deleted the scrabsha/compare-ip-addresses branch May 17, 2022 09:18
scrabsha added a commit to scrabsha/clickhouse-rs that referenced this pull request May 17, 2022
The problem here is similar to what is descibed at [1]: the
implementation of `PartialEq` for `Value` doesn't try to handle the
`DateTime64` variant.

This commit adds the corresponding match arm and actually performs the
equality check.

[1]: suharev7#172
scrabsha added a commit to scrabsha/clickhouse-rs that referenced this pull request May 17, 2022
The problem here is similar to what is descibed at [1]: the
implementation of `PartialEq` for `Value` doesn't try to handle the
`Enum8` and `DateTime64` variant.

This commit adds the corresponding match arms and actually performs the
equality checks.

[1]: suharev7#172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants