-
Notifications
You must be signed in to change notification settings - Fork 569
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
ScanStruct with a Nullable tuple value results in pointer value as text #1446
Comments
@SpencerTorres could you take a look? |
Hello! Thanks for submitting a code sample. I was able to re-create this issue immediately. ProblemThe issue is happening here: // lib/column/tuple.go:204
if field.Kind() == reflect.String {
if v := reflect.ValueOf(fmt.Sprint(value.Interface())); v.Type().AssignableTo(field.Type()) {
field.Set(v)
return nil
}
} The intent of this code is to allow your row The reason it's returning a pointer is because the What you should've seen is this:
SolutionSimply change I believe the code I linked should be deleted. It's trying to force a conversion by using I'll submit a PR to apply the suggested fix. Let me know if you have any further questions. Thanks! |
Thanks @SpencerTorres !
Odd didn't see it, or at least didn't notice it.
Wouldn't it be better if the call to |
Yes! The change in #1465 will return an error all the way to ScanStruct. If the conversion is not possible you will see the correct error returned |
Awesome, then I think you can close issue, thanks for the help! |
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: