Description
Bug Report
YDB GO SDK version:
v3.108.0
Environment
macOS Venture 13.4 pro M2
Current behavior:
When I try to scan a YDB column of type Decimal(22,9) into a struct field of type types.Decimal using ScanStruct, I get a cast error:
scan error on struct field name 'amount': cast failed 'Decimal(22,9)(&{value:[0 0 0 0 0 0 0 0 1 182 155 75 172 208 95 21] innerType:0x140002b8800})' to '*decimal.Decimal' destination at
github.com/ydb-platform/ydb-go-sdk/v3/internal/value.(*decimalValue).castTo(value.go:640)at
github.com/ydb-platform/ydb-go-sdk/v3/internal/value.(*optionalValue).castTo(value.go:1761)at
github.com/ydb-platform/ydb-go-sdk/v3/internal/query/scanner.StructScanner.ScanStruct(struct.go:68)at
github.com/ydb-platform/ydb-go-sdk/v3/internal/query.Row.ScanStruct(row.go:63)at
main.readTableDataWithDecimal(main.go:144)
`
Expected behavior:
I expect the Go SDK to support scanning Decimal columns into struct fields of type types.Decimal, similarly to how primitive types are mapped. The ScanStruct call should fill all fields without errors.
Steps to reproduce:
Create a table with a column of type Decimal(22,9) in YDB.
Define a Go struct with a field of type types.Decimal.
Select a row from the table using the Query Service and try to scan it into the struct using ScanStruct.
Observe a cast error for the decimal field.
Related code:
type RowData struct {
ID uint64 `sql:"id"`
Amount types.Decimal `sql:"amount"`
}
var info RowData
if err := row.ScanStruct(&info); err != nil {
return nil, fmt.Errorf("ошибка при сканировании строки: %w", err)
}