Skip to content

Commit 5a96158

Browse files
committed
added test for wrong query
1 parent b9d3521 commit 5a96158

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

internal/xerrors/join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func Join(errs ...error) joinError {
10-
return joinError(errs)
10+
return errs
1111
}
1212

1313
type joinError []error

tests/integration/table_scan_error_test.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"testing"
1111

1212
"github.com/stretchr/testify/require"
13-
"golang.org/x/xerrors"
1413

1514
"github.com/ydb-platform/ydb-go-sdk/v3"
1615
"github.com/ydb-platform/ydb-go-sdk/v3/table"
@@ -54,15 +53,31 @@ func TestIssue415ScanError(t *testing.T) {
5453
return res.Err()
5554
}, table.WithTxSettings(table.TxSettings(table.WithSnapshotReadOnly())))
5655
require.Error(t, err)
57-
err = func(err error) error {
58-
for {
59-
//nolint:errorlint
60-
if unwrappedErr, has := err.(xerrors.Wrapper); has {
61-
err = unwrappedErr.Unwrap()
62-
} else {
63-
return err
64-
}
65-
}
66-
}(err)
6756
require.ErrorContains(t, err, "not found column 'ghi'")
6857
}
58+
59+
// https://github.com/ydb-platform/ydb-go-sdk/issues/847
60+
func TestIssue847ScanError(t *testing.T) {
61+
ctx, cancel := context.WithCancel(context.Background())
62+
defer cancel()
63+
64+
db, err := ydb.Open(ctx,
65+
os.Getenv("YDB_CONNECTION_STRING"),
66+
ydb.WithAccessTokenCredentials(os.Getenv("YDB_ACCESS_TOKEN_CREDENTIALS")),
67+
)
68+
require.NoError(t, err)
69+
err = db.Table().Do(ctx, func(ctx context.Context, s table.Session) (err error) {
70+
res, err := s.StreamExecuteScanQuery(ctx, `SELICT 1;`, nil)
71+
if err != nil {
72+
return err
73+
}
74+
err = res.NextResultSetErr(ctx)
75+
if err != nil {
76+
return err
77+
}
78+
return res.Err()
79+
}, table.WithTxSettings(table.TxSettings(table.WithSnapshotReadOnly())))
80+
require.Error(t, err)
81+
t.Log(err)
82+
require.ErrorContains(t, err, "Unexpected token 'SELICT'")
83+
}

0 commit comments

Comments
 (0)