Skip to content

Commit fb6c054

Browse files
author
cruvie
committed
fix(values):Fix the issue of time. Duration type being incorrectly converted to int64
1 parent 74c6af3 commit fb6c054

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

values.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package pgx
33
import (
44
"errors"
55
"reflect"
6+
"time"
67

78
"github.com/jackc/pgx/v5/internal/pgio"
89
"github.com/jackc/pgx/v5/pgtype"
@@ -18,7 +19,9 @@ func convertSimpleArgument(m *pgtype.Map, arg any) (any, error) {
1819
fieldValue := reflect.ValueOf(arg)
1920
switch fieldValue.Kind() {
2021
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
21-
arg = fieldValue.Int()
22+
if _, ok := arg.(time.Duration); !ok {
23+
arg = fieldValue.Int()
24+
}
2225
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
2326
arg = fieldValue.Uint()
2427
}

0 commit comments

Comments
 (0)