mirror of
https://github.com/jackc/pgx.git
synced 2025-04-27 13:14:32 +00:00
Support time durations for simple protocol
Signed-off-by: Michael Darr <michael.e.darr@gmail.com>
This commit is contained in:
parent
1470d69c58
commit
59fa1868a7
13
conn_test.go
13
conn_test.go
@ -1061,3 +1061,16 @@ func TestStmtCacheInvalidationTx(t *testing.T) {
|
|||||||
|
|
||||||
ensureConnValid(t, conn)
|
ensureConnValid(t, conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestInsertDurationInterval(t *testing.T) {
|
||||||
|
testWithAndWithoutPreferSimpleProtocol(t, func(t *testing.T, conn *pgx.Conn) {
|
||||||
|
_, err := conn.Exec(context.Background(), "create temporary table t(duration INTERVAL(0) NOT NULL)")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
result, err := conn.Exec(context.Background(), "insert into t(duration) values($1)", time.Minute)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
n := result.RowsAffected()
|
||||||
|
require.EqualValues(t, 1, n)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -78,6 +78,8 @@ func convertSimpleArgument(ci *pgtype.ConnInfo, arg interface{}) (interface{}, e
|
|||||||
return arg, nil
|
return arg, nil
|
||||||
case bool:
|
case bool:
|
||||||
return arg, nil
|
return arg, nil
|
||||||
|
case time.Duration:
|
||||||
|
return fmt.Sprintf("%d microsecond", int64(arg)/1000), nil
|
||||||
case time.Time:
|
case time.Time:
|
||||||
return arg, nil
|
return arg, nil
|
||||||
case string:
|
case string:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user