mirror of
https://github.com/jackc/pgx.git
synced 2025-09-04 19:37:10 +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:
|
To use it add the following line to your imports:
|
||||||
|
|
||||||
```go
|
```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:
|
Then run the following to register the data type with a connection:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
conn.ConnInfo().RegisterDataType(pgtype.DataType{
|
pgxdecimal.Register(conn.TypeMap())
|
||||||
Value: &shopspring.Numeric{},
|
|
||||||
Name: "numeric",
|
|
||||||
OID: pgtype.NumericOID,
|
|
||||||
})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using `pgxpool` the previous command should be run in an `AfterConnect` hook to ensure it is available on every connection.
|
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