mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
fix: fix ignored scanner.Err() (#4063)
This commit is contained in:
parent
a66ae0d4c4
commit
682460c1c8
@ -248,7 +248,7 @@ func unmarshalRows(v any, scanner rowsScanner, strict bool) error {
|
||||
return ErrUnsupportedValueType
|
||||
}
|
||||
|
||||
return nil
|
||||
return scanner.Err()
|
||||
default:
|
||||
return ErrUnsupportedValueType
|
||||
}
|
||||
|
@ -291,19 +291,19 @@ func TestStmtBreaker(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestQueryScanTimeout(t *testing.T) {
|
||||
func TestQueryRowsScanTimeout(t *testing.T) {
|
||||
dbtest.RunTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
|
||||
defer cancel()
|
||||
row := sqlmock.NewRows([]string{"foo"})
|
||||
rows := sqlmock.NewRows([]string{"foo"})
|
||||
for i := 0; i < 10000; i++ {
|
||||
row = row.AddRow("bar" + strconv.Itoa(i))
|
||||
rows = rows.AddRow("bar" + strconv.Itoa(i))
|
||||
}
|
||||
mock.ExpectQuery("any").WillReturnRows(rows)
|
||||
var val []struct {
|
||||
Foo int
|
||||
Bar string
|
||||
Foo string
|
||||
}
|
||||
conn := NewSqlConnFromDB(db)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
|
||||
defer cancel()
|
||||
err := conn.QueryRowsCtx(ctx, &val, "any")
|
||||
assert.ErrorIs(t, err, context.DeadlineExceeded)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user