Skip to content

Conversation

@chernser
Copy link
Contributor

@chernser chernser commented May 16, 2025

Summary

Fixes address conversion when actual value is IPv4 and column is IPv6
Closes #2342

Checklist

Delete items not relevant to your PR:

Copy link

Copilot AI left a 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.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
58.2% Coverage on New Code (required ≥ 80%)
26.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@chernser chernser merged commit db60351 into main May 16, 2025
23 checks passed
@chernser chernser deleted the fix_ip_v6 branch May 16, 2025 13:28
@chernser
Copy link
Contributor Author

/windsurf-review

Copy link
Contributor

@windsurf-bot windsurf-bot bot left a 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
Copy link
Contributor

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
Copy link
Contributor

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 {
Copy link
Contributor

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.).

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.

[jdbc-v2] IpV4/IpV6 Conversion is not working

3 participants