mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 15:10:01 +08:00
fix: fix ignored context.DeadlineExceeded (#4066)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package sqlx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -87,6 +88,10 @@ func getValueInterface(value reflect.Value) (any, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func isScanFailed(err error) bool {
|
||||
return err != nil && !errors.Is(err, context.DeadlineExceeded)
|
||||
}
|
||||
|
||||
func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]any, error) {
|
||||
fields := unwrapFields(v)
|
||||
if strict && len(columns) < len(fields) {
|
||||
|
||||
@@ -296,7 +296,7 @@ func (db *commonSqlConn) queryRows(ctx context.Context, scanner func(*sql.Rows)
|
||||
|
||||
return query(ctx, conn, func(rows *sql.Rows) error {
|
||||
e := scanner(rows)
|
||||
if e != nil && !errors.Is(e, context.DeadlineExceeded) {
|
||||
if isScanFailed(e) {
|
||||
scanFailed = true
|
||||
}
|
||||
return e
|
||||
|
||||
@@ -144,7 +144,7 @@ func (s statement) queryRows(ctx context.Context, scanFn func(any, rowsScanner)
|
||||
err := s.brk.DoWithAcceptable(func() error {
|
||||
return queryStmt(ctx, s.stmt, func(rows *sql.Rows) error {
|
||||
err := scanFn(v, rows)
|
||||
if err != nil {
|
||||
if isScanFailed(err) {
|
||||
scanFailed = true
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user