2
0

Unregistered OIDs are handled the same as unknown OIDs

This improves handling of unregistered types. In general, they should
"just work". But there are performance benefits gained and some edge
cases avoided by registering types. Updated documentation to mention
this.

https://github.com/jackc/pgx/issues/1445
This commit is contained in:
Jack Christensen
2022-12-23 13:11:28 -06:00
parent d737852654
commit 456a242f5c
5 changed files with 121 additions and 34 deletions
+19 -1
View File
@@ -190,7 +190,7 @@ func TestConnQueryValuesWhenUnableToDecode(t *testing.T) {
require.Equal(t, "({1},)", values[0])
}
func TestConnQueryValuesWithUnknownOID(t *testing.T) {
func TestConnQueryValuesWithUnregisteredOID(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
@@ -217,6 +217,24 @@ func TestConnQueryValuesWithUnknownOID(t *testing.T) {
require.Equal(t, "orange", values[0])
}
func TestConnQueryArgsAndScanWithUnregisteredOID(t *testing.T) {
t.Parallel()
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
tx, err := conn.Begin(ctx)
require.NoError(t, err)
defer tx.Rollback(ctx)
_, err = tx.Exec(ctx, "create type fruit as enum('orange', 'apple', 'pear')")
require.NoError(t, err)
var result string
err = conn.QueryRow(ctx, "select $1::fruit", "orange").Scan(&result)
require.NoError(t, err)
require.Equal(t, "orange", result)
})
}
// https://github.com/jackc/pgx/issues/478
func TestConnQueryReadRowMultipleTimes(t *testing.T) {
t.Parallel()