Documentation
¶
Index ¶
- func Array(a any) interface{ ... }
- func EnableInfinityTs(negative time.Time, positive time.Time)
- func FormatTimestamp(t time.Time) []byte
- func ParseTimestamp(currentLocation *time.Location, str string) (time.Time, error)
- type ArrayDelimiter
- type BoolArray
- type ByteaArray
- type Float32Array
- type Float64Array
- type GenericArray
- type Int32Array
- type Int64Array
- type NullTime
- type StringArray
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.
func FormatTimestamp ¶
FormatTimestamp formats t into Postgres' text format for timestamps.
func ParseTimestamp ¶
ParseTimestamp parses Postgres' text format. It returns a time.Time in currentLocation iff that time's offset agrees with the offset sent from the Postgres server. Otherwise, ParseTimestamp returns a time.Time with the fixed offset offset provided by the Postgres server.
Types ¶
type ArrayDelimiter ¶
type ArrayDelimiter interface { // ArrayDelimiter returns the delimiter character(s) for this element's type. ArrayDelimiter() string }
ArrayDelimiter may be optionally implemented by driver.Valuer or sql.Scanner to override the array delimiter used by GenericArray.
type BoolArray ¶
type BoolArray []bool
BoolArray represents a one-dimensional array of the PostgreSQL boolean type.
type ByteaArray ¶
type ByteaArray [][]byte
ByteaArray represents a one-dimensional array of the PostgreSQL bytea type.
func (*ByteaArray) Scan ¶
func (a *ByteaArray) Scan(src any) error
Scan implements the sql.Scanner interface.
type Float32Array ¶
type Float32Array []float32
Float32Array represents a one-dimensional array of the PostgreSQL double precision type.
func (*Float32Array) Scan ¶
func (a *Float32Array) Scan(src any) error
Scan implements the sql.Scanner interface.
type Float64Array ¶
type Float64Array []float64
Float64Array represents a one-dimensional array of the PostgreSQL double precision type.
func (*Float64Array) Scan ¶
func (a *Float64Array) Scan(src any) error
Scan implements the sql.Scanner interface.
type GenericArray ¶
type GenericArray struct{ A any }
GenericArray implements the driver.Valuer and sql.Scanner interfaces for an array or slice of any dimension.
func (GenericArray) Scan ¶
func (a GenericArray) Scan(src any) error
Scan implements the sql.Scanner interface.
type Int32Array ¶
type Int32Array []int32
Int32Array represents a one-dimensional array of the PostgreSQL integer types.
func (*Int32Array) Scan ¶
func (a *Int32Array) Scan(src any) error
Scan implements the sql.Scanner interface.
type Int64Array ¶
type Int64Array []int64
Int64Array represents a one-dimensional array of the PostgreSQL integer types.
func (*Int64Array) Scan ¶
func (a *Int64Array) Scan(src any) error
Scan implements the sql.Scanner interface.
type NullTime ¶
NullTime represents a time.Time that may be null. NullTime implements the sql.Scanner interface so it can be used as a scan destination, similar to sql.NullString.
type StringArray ¶
type StringArray []string
StringArray represents a one-dimensional array of the PostgreSQL character types.
func (*StringArray) Scan ¶
func (a *StringArray) Scan(src any) error
Scan implements the sql.Scanner interface.