We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using ScanStruct to scan a tuple containing a nullable string the driver will insert the pointer address as a string into the struct.
ScanStruct
Or with other words:
Nullable
string
'0xc00052f790'
(The behavior is correct when not using nullable values)
Either the ScanStruct operation should fail, or null values are mapped to "".
null
""
The code does the following:
Row
myRow.MyTuple.TupleOne)
package code type Tuple struct { TupleOne string `ch:"tuple_one"` TupleTwo string `ch:"tuple_two"` } type Row struct { MyId uint64 `ch:"my_id"` MyTuple Tuple `ch:"my_tuple"` } func TestBug(t *testing.T) { ctx := context.Background() db := // Db setup code createdDb := ` create table if not exists my_table( my_id UInt64, my_tuple Tuple(tuple_one Nullable(String), tuple_two Nullable(String)) ) engine = MergeTree primary key (my_id) order by (my_id) ` if err := db.Exec(ctx, createdDb); err != nil { t.Fatal(err) } if err := db.Exec(ctx, "insert into my_table(my_id, my_tuple) values (1, tuple('one', 'two'))"); err != nil { t.Fatal(err) } myRow := Row{} if err := db.QueryRow(ctx, "select * from my_table limit 1").ScanStruct(&myRow); err != nil { t.Fatal(err) } if myRow.MyTuple.TupleOne != "one" { t.Errorf("Expected 'one' but got '%s'", myRow.MyTuple.TupleOne) } if myRow.MyTuple.TupleTwo != "two" { t.Errorf("Expected 'two' but got '%s'", myRow.MyTuple.TupleTwo) } }
The result will be:
bug_test.go:48: Expected 'one' but got '0xc00052f790' bug_test.go:52: Expected 'two' but got '0xc00052f7c0'
clickhouse-go
database/sql
CREATE TABLE
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Observed
When using
ScanStruct
to scan a tuple containing a nullable string the driver will insert the pointer address as a string into the struct.Or with other words:
Nullable
string.ScanStruct
the row into a struct with astring
field.'0xc00052f790'
(The behavior is correct when not using nullable values)
Expected behaviour
Either the
ScanStruct
operation should fail, ornull
values are mapped to""
.Code example
The code does the following:
Row
usingScanStruct
.myRow.MyTuple.TupleOne)
now contains a pointer as string, instead of the actual value.The result will be:
Details
Environment
clickhouse-go
version: v2.30.0database/sql
compatible driverCREATE TABLE
statements for tables involved: See code exampleThe text was updated successfully, but these errors were encountered: