Documentation ¶
Overview ¶
Package dbarray provides support for database array types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Array ¶
Array returns the optimal driver.Valuer and sql.Scanner for an array or slice of any dimension.
For example:
db.Query(`SELECT * FROM t WHERE id = ANY($1)`, pq.Array([]int{235, 401})) var x []sql.NullInt64 db.QueryRow(`SELECT ARRAY[235, 401]`).Scan(pq.Array(&x))
Scanning multi-dimensional arrays is not supported. Arrays where the lower bound is not one (such as `[0:0]={1}') are not supported.
func EnableInfinityTS ¶
EnableInfinityTS controls the handling of Postgres' "-infinity" and "infinity" "timestamp"s.
If EnableInfinityTS is not called, "-infinity" and "infinity" will return []byte("-infinity") and []byte("infinity") respectively, and potentially cause error "sql: Scan error on column index 0: unsupported driver -> Scan pair: []uint8 -> *time.Time", when scanning into a time.Time value.
Once EnableInfinityTS has been called, all connections created using this driver will decode Postgres' "-infinity" and "infinity" for "timestamp", "timestamp with time zone" and "date" types to the predefined minimum and maximum times, respectively. When encoding time.Time values, any time which equals or precedes the predefined minimum time will be encoded to "-infinity". Any values at or past the maximum time will similarly be encoded to "infinity".
If EnableInfinityTS is called with negative >= positive, it will panic. Calling EnableInfinityTS after a connection has been established results in undefined behavior. If EnableInfinityTS is called more than once, it will panic.
Types ¶
type Bool ¶
type Bool []bool
Bool represents a one-dimensional array of the PostgreSQL boolean type.
type Bytea ¶
type Bytea [][]byte
Bytea represents a one-dimensional array of the PostgreSQL bytea type.
type Delimiter ¶
type Delimiter interface { // Delimiter returns the delimiter character(s) for this element's type. Delimiter() string }
Delimiter may be optionally implemented by driver.Valuer or sql.Scanner to override the array delimiter used by Generic.
type Float32 ¶
type Float32 []float32
Float32 represents a one-dimensional array of the PostgreSQL double precision type.
type Float64 ¶
type Float64 []float64
Float64 represents a one-dimensional array of the PostgreSQL double precision type.
type Generic ¶
type Generic struct{ A any }
Generic implements the driver.Valuer and sql.Scanner interfaces for an array or slice of any dimension.
type Int32 ¶
type Int32 []int32
Int32 represents a one-dimensional array of the PostgreSQL integer types.
type Int64 ¶
type Int64 []int64
Int64 represents a one-dimensional array of the PostgreSQL integer types.