pgxmoney

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pgxmoney 把 Postgres NUMERIC ↔ shopspring/decimal 的编解码注册进 pgx v5 的 type map,供 sqlc 生成代码与手写查询直接以 decimal.Decimal 读写 NUMERIC 列(全系统禁 float 金额的数据库侧落点)。

实现方式是桥接 pgtype.NumericCodec:包内 wrapper 类型实现 pgtype.NumericValuer / NumericScanner,经 TryWrap*PlanFuncs 把 decimal.Decimal 转到 wrapper,编解码本身仍走内建 codec(文本与二进制 两种线格式都覆盖),不引入额外依赖。

Deprecated: 本包没有存在必要。shopspring/decimal 自带 driver.Valuer 与 sql.Scanner,pgx v5 对未注册的类型自动回落到这两个接口——实测有无本包, decimal.Decimal 读写 NUMERIC 的结果完全一致(含数组、NULL、CopyFrom、 Batch、简单协议、高精度)。新代码直接用 decimal.Decimal 即可,不要接入。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register deprecated

func Register(conn *pgx.Conn)

Register 把 NUMERIC ↔ decimal.Decimal 编解码注册到 conn 的 type map。 type map 归单个连接所有,因此要在建连钩子里对每条连接调用 (pgxpool.Config.AfterConnect)。

Deprecated: 无需注册,见包文档。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL