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

feat:

Open weres-sa opened this issue 11 months ago • 0 comments

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

weres-sa avatar Mar 25 '24 14:03 weres-sa