@@ -21,13 +21,14 @@ import (
2121 "context"
2222 "database/sql/driver"
2323 "fmt"
24- "github.com/ClickHouse/ch-go/proto"
25- "github.com/ClickHouse/clickhouse-go/v2/lib/column"
26- "github.com/stretchr/testify/require"
2724 "net"
2825 "net/netip"
2926 "testing"
3027
28+ "github.com/ClickHouse/ch-go/proto"
29+ "github.com/ClickHouse/clickhouse-go/v2/lib/column"
30+ "github.com/stretchr/testify/require"
31+
3132 "github.com/ClickHouse/clickhouse-go/v2"
3233 "github.com/stretchr/testify/assert"
3334)
@@ -520,3 +521,44 @@ func TestIPv6Valuer(t *testing.T) {
520521 }
521522 require .Equal (t , 1000 , i )
522523}
524+
525+ func TestSQLScannerIPv6 (t * testing.T ) {
526+ conn , err := GetNativeConnection (nil , nil , & clickhouse.Compression {
527+ Method : clickhouse .CompressionLZ4 ,
528+ })
529+ ctx := context .Background ()
530+ require .NoError (t , err )
531+ const ddl = `
532+ CREATE TABLE test_ipv6 (
533+ Col1 IPv6
534+ ) Engine MergeTree() ORDER BY tuple()
535+ `
536+ defer func () {
537+ conn .Exec (ctx , "DROP TABLE test_ipv6" )
538+ }()
539+
540+ require .NoError (t , conn .Exec (ctx , ddl ))
541+ batch , err := conn .PrepareBatch (ctx , "INSERT INTO test_ipv6" )
542+ require .NoError (t , err )
543+
544+ var (
545+ col1Data = net .ParseIP ("2001:44c8:129:2632:33:0:252:2" )
546+ )
547+ require .NoError (t , batch .Append (col1Data ))
548+ require .Equal (t , 1 , batch .Rows ())
549+ require .NoError (t , batch .Send ())
550+ var (
551+ col1 sqlScannerIPv6
552+ )
553+ require .NoError (t , conn .QueryRow (ctx , "SELECT * FROM test_ipv6" ).Scan (& col1 ))
554+ assert .Equal (t , col1Data , col1 .value )
555+ }
556+
557+ type sqlScannerIPv6 struct {
558+ value any
559+ }
560+
561+ func (s * sqlScannerIPv6 ) Scan (src any ) error {
562+ s .value = src
563+ return nil
564+ }
0 commit comments