ydb-go-sdk icon indicating copy to clipboard operation
ydb-go-sdk copied to clipboard

bug: When using `Text` columns, ScanStruct does not work for pointer struct field & and the column is mandatory

Open flymedllva opened this issue 8 months ago • 0 comments

Bug Report

YDB GO SDK version:

v3.71.0

Description:

When using Text columns, ScanStruct does not work for pointer struct field](bug: When using Text columns, ScanStruct does not work for pointer struct field & and the column is mandatory)

CREATE TABLE `test`
(
    `id`         Text NOT NULL
);
type T struct {
	ID        *string   `sql:"id"`
}

Not work, error: cannot cast 'TEST' (type 'Utf8') to '**string' destination at github.com/ydb-platform/ydb-go-sdk/v3/internal/value.textValue.castTo(value.go:2046) at `github.com/ydb-platform/ydb-go-sdk/v3/internal/query/scanner.StructScanner.ScanStruct(struct.go:64)

row, err := s.ydbConn.Query().ReadResultSet(ctx, "select id from `test`;")
nextRow, err := row.NextRow(ctx)
var t T
err = nextRow.ScanStruct(&t, query.WithScanStructAllowMissingColumnsFromSelect(), query.WithScanStructAllowMissingFieldsInStruct())

flymedllva avatar Jun 06 '24 00:06 flymedllva