Temporarily switch to admin role to register types
The authenticator role does not have access to the numerus schema, so it can not see the oid of discount_rate, for instance.
This commit is contained in:
parent
18fba2964f
commit
191401abe9
|
@ -35,6 +35,9 @@ func (src NewInvoiceProductArray) EncodeBinary(ci *pgtype.ConnInfo, buf []byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerPgTypes(ctx context.Context, conn *pgx.Conn) error {
|
func registerPgTypes(ctx context.Context, conn *pgx.Conn) error {
|
||||||
|
if _, err := conn.Exec(ctx, "set role to admin"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
discountRateOID, err := registerPgType(ctx, conn, &pgtype.Numeric{}, "discount_rate")
|
discountRateOID, err := registerPgType(ctx, conn, &pgtype.Numeric{}, "discount_rate")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -67,7 +70,9 @@ func registerPgTypes(ctx context.Context, conn *pgx.Conn) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
_, err = conn.Exec(ctx, "reset role")
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerPgType(ctx context.Context, conn *pgx.Conn, value pgtype.Value, name string) (oid uint32, err error) {
|
func registerPgType(ctx context.Context, conn *pgx.Conn, value pgtype.Value, name string) (oid uint32, err error) {
|
||||||
|
|
Loading…
Reference in New Issue