-
Hi, I'm trying to migrate a project to google uuid library. I'm using import (
"github.com/jackc/pgtype"
pgtypeuuid "github.com/jackc/pgtype/ext/gofrs-uuid"
"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v4/pgxpool"
)
config, err := pgxpool.ParseConfig(dbUrlWithMaxConnections)
if err != nil {
log.Fatal().Err(err).Msg("Unable to open config connection pool")
}
config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
conn.ConnInfo().RegisterDataType(pgtype.DataType{
Value: &pgtypeuuid.UUID{},
Name: "uuid",
OID: pgtype.UUIDOID,
})
return nil
}
dbPool, err := pgxpool.ConnectConfig(context.Background(), config) |
Beta Was this translation helpful? Give feedback.
Answered by
jackc
Jan 24, 2023
Replies: 1 comment 1 reply
-
pgx v4 does not have a built-in adapter for the Google UUID library. It still work though (albeit a little slower) -- pgx v4 is compatible with database/sql And there is a 3rd party adapter for pgx v5 https://github.com/vgarvardt/pgx-google-uuid. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
soasada
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pgx v4 does not have a built-in adapter for the Google UUID library. It still work though (albeit a little slower) -- pgx v4 is compatible with database/sql
Scanner
andValuer
.And there is a 3rd party adapter for pgx v5 https://github.com/vgarvardt/pgx-google-uuid.