ydb-go-sdk
ydb-go-sdk copied to clipboard
feat:
Feature Request
Make an error about optional/required value mismatch more clear.
Describe Preferred Solution
Improve error message with exact error reason and column name
Describe Alternatives
Now error message looks like: `scan row failed: incorrect source types PRIMITIVE_TYPE_ID_UNSPECIFIED
It seems rather confusing.
Related Code
Additional Context
It seems that two small fixes would be enough for that purpose: In https://github.com/ydb-platform/ydb-go-sdk/blob/master/internal/table/scanner/scanner.go#L813
if s.isNull() {
_ = s.errorf(0, "scan row failed: got unexpected null value; You may want use named.Optional instead?.", )
}
And in https://github.com/ydb-platform/ydb-go-sdk/blob/master/internal/table/scanner/scanner.go#L192-L194
if err := s.seekItemByName(namedValues[i].Name); err != nil {
return xerrors.Wrap(
fmt.Errorf("fail to scan column %s: %w", namedValues[i].Name, err),
)
}
If the feature request is approved, would you be willing to submit a PR? Yes