-
Notifications
You must be signed in to change notification settings - Fork 614
[jdbc-v2] Fixes IPv6 address conversion into IPv4 #2369
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
Conversation
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.
Pull Request Overview
This PR fixes the conversion of IPv6 address columns when the actual value is an IPv4 address by updating tests and conversion utilities.
- Updated tests to include a new column "ipv4_as_ipv6" and corresponding assertions.
- Added an InetAddressConverter to handle IPv4-to-IPv6 and IPv6-to-IPv4 conversions.
- Modified various reader methods to use the new conversion utility.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java | Added tests for IPv4-as-IPv6 conversion and updated table schema/insertion. |
| client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java | Introduced a new integration test for IP address conversion and updated test group categorization. |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java | Added necessary imports to support InetAddress conversion. |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/MapBackedRecord.java | Modified IP address getter methods to use the new conversion utility. |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/InetAddressConverter.java | New utility class providing methods to convert between IPv4 and IPv6. |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java | Updated IP address read methods to use InetAddressConverter for consistent conversion handling. |
client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
|
|
/windsurf-review |
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.
1 file skipped due to size limits:
- client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java
| /** | ||
| * Converts IPv4 address to IPv6 address. | ||
| * | ||
| * @param value IPv4 address |
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 Javadoc for convertToIpv6 method should be updated to clarify that it accepts any InetAddress (including null and IPv6 addresses), not just IPv4 addresses as currently stated.
| /** | ||
| * Converts IPv6 address to IPv4 address if applicable. | ||
| * | ||
| * @param value IPv6 address |
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 Javadoc for convertToIpv4 method should be updated to clarify that it accepts any InetAddress (including null and IPv4 addresses), not just IPv6 addresses as currently stated.
| import java.net.InetAddress; | ||
| import java.net.UnknownHostException; | ||
|
|
||
| public class InetAddressConverter { |
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.
According to the project guidelines, tests are required for new functionality. Please include unit tests for this converter class to verify both conversion methods work correctly with various edge cases (null values, valid IPv4/IPv6 addresses, invalid conversions, etc.).


Summary
Fixes address conversion when actual value is IPv4 and column is IPv6
Closes #2342
Checklist
Delete items not relevant to your PR: