mirror of
https://github.com/jackc/pgx.git
synced 2025-07-11 21:19:37 +00:00
Update for pgx v5
parent
e7c1e19282
commit
28fe4c34fe
@ -7,17 +7,13 @@ The recommended solution is to use the [github.com/shopspring/decimal](https://g
|
||||
To use it add the following line to your imports:
|
||||
|
||||
```go
|
||||
shopspring "github.com/jackc/pgtype/ext/shopspring-numeric"
|
||||
pgxdecimal "github.com/jackc/pgx-shopspring-decimal"
|
||||
```
|
||||
|
||||
Then run the following to register the data type with a connection:
|
||||
|
||||
```go
|
||||
conn.ConnInfo().RegisterDataType(pgtype.DataType{
|
||||
Value: &shopspring.Numeric{},
|
||||
Name: "numeric",
|
||||
OID: pgtype.NumericOID,
|
||||
})
|
||||
pgxdecimal.Register(conn.TypeMap())
|
||||
```
|
||||
|
||||
If you are using `pgxpool` the previous command should be run in an `AfterConnect` hook to ensure it is available on every connection.
|
||||
|
Loading…
x
Reference in New Issue
Block a user