mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-11 00:40:00 +08:00
fix: fix ignored context.DeadlineExceeded (#4066)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package sqlx
|
package sqlx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"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) {
|
func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]any, error) {
|
||||||
fields := unwrapFields(v)
|
fields := unwrapFields(v)
|
||||||
if strict && len(columns) < len(fields) {
|
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 {
|
return query(ctx, conn, func(rows *sql.Rows) error {
|
||||||
e := scanner(rows)
|
e := scanner(rows)
|
||||||
if e != nil && !errors.Is(e, context.DeadlineExceeded) {
|
if isScanFailed(e) {
|
||||||
scanFailed = true
|
scanFailed = true
|
||||||
}
|
}
|
||||||
return e
|
return e
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ func (s statement) queryRows(ctx context.Context, scanFn func(any, rowsScanner)
|
|||||||
err := s.brk.DoWithAcceptable(func() error {
|
err := s.brk.DoWithAcceptable(func() error {
|
||||||
return queryStmt(ctx, s.stmt, func(rows *sql.Rows) error {
|
return queryStmt(ctx, s.stmt, func(rows *sql.Rows) error {
|
||||||
err := scanFn(v, rows)
|
err := scanFn(v, rows)
|
||||||
if err != nil {
|
if isScanFailed(err) {
|
||||||
scanFailed = true
|
scanFailed = true
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -35,6 +35,5 @@ LABEL org.opencontainers.image.description="A cloud-native Go microservices fram
|
|||||||
LABEL org.opencontainers.image.licenses="MIT"
|
LABEL org.opencontainers.image.licenses="MIT"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/zeromicro/go-zero"
|
LABEL org.opencontainers.image.source="https://github.com/zeromicro/go-zero"
|
||||||
LABEL org.opencontainers.image.title="goctl (cli)"
|
LABEL org.opencontainers.image.title="goctl (cli)"
|
||||||
LABEL org.opencontainers.image.version="v1.6.3"
|
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/goctl"]
|
ENTRYPOINT ["/usr/local/bin/goctl"]
|
||||||
|
|||||||
Reference in New Issue
Block a user