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 ErrUnsupportedValueType
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return scanner.Err()
|
||||||
default:
|
default:
|
||||||
return ErrUnsupportedValueType
|
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) {
|
dbtest.RunTest(t, func(db *sql.DB, mock sqlmock.Sqlmock) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
|
rows := sqlmock.NewRows([]string{"foo"})
|
||||||
defer cancel()
|
|
||||||
row := sqlmock.NewRows([]string{"foo"})
|
|
||||||
for i := 0; i < 10000; i++ {
|
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 {
|
var val []struct {
|
||||||
Foo int
|
Foo string
|
||||||
Bar string
|
|
||||||
}
|
}
|
||||||
conn := NewSqlConnFromDB(db)
|
conn := NewSqlConnFromDB(db)
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
|
||||||
|
defer cancel()
|
||||||
err := conn.QueryRowsCtx(ctx, &val, "any")
|
err := conn.QueryRowsCtx(ctx, &val, "any")
|
||||||
assert.ErrorIs(t, err, context.DeadlineExceeded)
|
assert.ErrorIs(t, err, context.DeadlineExceeded)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user