Documentation
¶
Index ¶
- Constants
- func ClosePool(ctx context.Context, pool *pgxpool.Pool, log logger.Logger)
- func DateToTime(d pgtype.Date) time.Time
- func IsCheckViolation(err error) bool
- func IsForeignKeyViolation(err error) bool
- func IsNoRows(err error) bool
- func IsUniqueViolation(err error) bool
- func IsValueTooLong(err error) bool
- func NewPool(ctx context.Context, cfg config.DBConfig, log logger.Logger) (*pgxpool.Pool, error)
- func TimeToDate(t time.Time) pgtype.Date
- func TimeToTimestampz(t time.Time) pgtype.Timestamptz
- func TimestampzToTimePtr(ts pgtype.Timestamptz) *time.Time
- type TxManager
Constants ¶
const ( CodeForeignKeyViolation = "23503" CodeUniqueViolation = "23505" CodeCheckViolation = "23514" CodeStringDataTruncation = "22001" CodeNumericValueOutOfRange = "22003" )
PostgreSQL error codes used to map driver errors to repository sentinels. See: https://www.postgresql.org/docs/current/errcodes-appendix.html
Variables ¶
This section is empty.
Functions ¶
func DateToTime ¶ added in v0.5.0
DateToTime converts a non-null Postgres date to a UTC-midnight time.
func IsCheckViolation ¶ added in v0.4.0
IsCheckViolation reports whether err is a CHECK constraint failure.
func IsForeignKeyViolation ¶ added in v0.4.0
IsForeignKeyViolation reports whether err is a foreign_key_violation.
func IsUniqueViolation ¶ added in v0.4.0
IsUniqueViolation reports whether err is a Postgres unique_violation (e.g. unique index).
func IsValueTooLong ¶ added in v0.4.0
IsValueTooLong reports whether err is a string_data_right_truncation (VARCHAR overflow).
func TimeToDate ¶ added in v0.5.0
TimeToDate wraps the calendar date portion of t into a valid pgtype.Date.
func TimeToTimestampz ¶ added in v0.5.0
func TimeToTimestampz(t time.Time) pgtype.Timestamptz
TimeToTimestampz wraps a time.Time into a valid pgtype.Timestamptz for a query parameter.
func TimestampzToTimePtr ¶ added in v0.5.0
func TimestampzToTimePtr(ts pgtype.Timestamptz) *time.Time
TimestampzToTimePtr converts a nullable pgtype.Timestamptz to *time.Time.