Skip to content

Commit

Permalink
fix: fix creation of Inet6Address. force Inet6Address.getByAddress to…
Browse files Browse the repository at this point in the history
… return Inet6Address.
  • Loading branch information
samssh committed Feb 12, 2025
1 parent e37c105 commit 92ce312
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
return (T) Inet4Address.getByAddress(readNBytesLE(input, 4));
case IPv6:
// https://clickhouse.com/docs/en/sql-reference/data-types/ipv6
return (T) Inet6Address.getByAddress(readNBytes(input, 16));
return (T) Inet6Address.getByAddress(null, readNBytes(input, 16), null);
case UUID:
return (T) new UUID(readLongLE(), readLongLE());
case Point:
Expand Down
12 changes: 12 additions & 0 deletions jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -926,4 +926,16 @@ public void testTypeConversions() throws Exception {
}
}
}

@Test(groups = "integration")
void testIPv6MappedToIPv4() throws Exception {
try (Connection conn = getJdbcConnection()) {
try (Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery("select toIPv6('::ffff:1.1.1.1')");
assertTrue(rs.next());
assertEquals(rs.getString(1), "/0:0:0:0:0:ffff:101:101");
assertFalse(rs.next());
}
}
}
}

0 comments on commit 92ce312

Please sign in to comment.