pgtypes

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array[T any] []T

Array is a one-dimensional Postgres array. A nil Array is a SQL NULL, an empty non-nil Array is an empty array.

It implements sql.Scanner and driver.Valuer for use with database/sql drivers such as lib/pq and pgx/stdlib, and pgtype.ArraySetter and pgtype.ArrayGetter so that it is natively scanned and encoded by pgx. Scan accepts both the text array literal and the pgx binary wire format, so it also works when wrapped by another sql.Scanner (e.g. null.Val or sql.Null).

func (Array[T]) Dimensions added in v0.51.0

func (a Array[T]) Dimensions() []pgtype.ArrayDimension

Dimensions implements the pgtype.ArrayGetter interface.

func (Array[T]) Index added in v0.51.0

func (a Array[T]) Index(i int) any

Index implements the pgtype.ArrayGetter interface.

func (Array[T]) IndexType added in v0.51.0

func (a Array[T]) IndexType() any

IndexType implements the pgtype.ArrayGetter interface.

func (*Array[T]) Scan

func (a *Array[T]) Scan(src any) error

Scan implements the sql.Scanner interface.

func (Array[T]) ScanIndex added in v0.51.0

func (a Array[T]) ScanIndex(i int) any

ScanIndex implements the pgtype.ArraySetter interface.

func (Array[T]) ScanIndexType added in v0.51.0

func (a Array[T]) ScanIndexType() any

ScanIndexType implements the pgtype.ArraySetter interface.

func (*Array[T]) SetDimensions added in v0.51.0

func (a *Array[T]) SetDimensions(dimensions []pgtype.ArrayDimension) error

SetDimensions implements the pgtype.ArraySetter interface. Multi-dimensional arrays are flattened.

func (Array[T]) Value

func (a Array[T]) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type EnumArray

type EnumArray[T ~string] = Array[T]

EnumArray is an Array of a Postgres enum type.

type HStore

type HStore map[string]sql.Null[string]

HStore is a wrapper for transferring HStore values back and forth easily.

func (*HStore) Scan

func (h *HStore) Scan(value any) error

Scan implements the Scanner interface.

Note h is reallocated before the scan to clear existing values. If the hstore column's database value is NULL, then h is set to nil instead.

func (HStore) String added in v0.37.0

func (h HStore) String() string

func (HStore) Value

func (h HStore) Value() (driver.Value, error)

Value implements the driver Valuer interface. Note if h is nil, the database column value will be set to NULL.

type Inet

type Inet struct {
	netip.Prefix
}

func (*Inet) Scan

func (i *Inet) Scan(src any) error

Scan implements the sql.Scanner interface.

func (Inet) Value

func (i Inet) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type LSN

type LSN uint64

func (*LSN) Scan

func (lsn *LSN) Scan(src any) error

Scan implements the sql.Scanner interface.

func (LSN) Value

func (lsn LSN) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Macaddr

type Macaddr struct {
	Addr net.HardwareAddr
}

func (*Macaddr) Scan

func (dst *Macaddr) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (Macaddr) Value

func (src Macaddr) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Snapshot added in v0.35.0

type Snapshot struct {
	Min    uint64
	Max    uint64
	Active []uint64
}

func (*Snapshot) Scan added in v0.35.0

func (t *Snapshot) Scan(src any) error

Scan implements the sql.Scanner interface.

func (Snapshot) String added in v0.35.0

func (t Snapshot) String() string

String returns the string representation of the TSQuery. xmin:xmax:xip_list

func (Snapshot) Value added in v0.35.0

func (t Snapshot) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type TSVector

type TSVector struct {
	// contains filtered or unexported fields
}

func (*TSVector) Scan

func (t *TSVector) Scan(src any) error

Scan implements the sql.Scanner interface.

func (TSVector) String

func (t TSVector) String() string

String returns the string representation of the TSVector.

func (TSVector) Value

func (t TSVector) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Jump to

Keyboard shortcuts

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