Documentation ¶
Index ¶
- Variables
- func Array(a interface{}) 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 HStore
- type Int32Array
- type Int64Array
- type Oid
- type StringArray
Constants ¶
This section is empty.
Variables ¶
var TypeName = map[Oid]string{}/* 167 elements not displayed */
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. If need, suggest use pgtype(https://github.com/jackc/pgtype)
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 interface{}) 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 interface{}) 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 interface{}) error
Scan implements the sql.Scanner interface.
type GenericArray ¶
type GenericArray struct{ A interface{} }
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 interface{}) error
Scan implements the sql.Scanner interface.
type HStore ¶ added in v1.13.1
type HStore struct {
Map map[string]sql.NullString
}
HStore is a wrapper for transferring HStore values back and forth easily.
type Int32Array ¶
type Int32Array []int32
Int32Array represents a one-dimensional array of the PostgreSQL integer types.
func (*Int32Array) Scan ¶
func (a *Int32Array) Scan(src interface{}) 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 interface{}) error
Scan implements the sql.Scanner interface.
type Oid ¶
type Oid uint32
Oid is a Postgres Object ID.
const ( T_bool Oid = 16 T_bytea Oid = 17 T_char Oid = 18 T_name Oid = 19 T_int8 Oid = 20 T_int2 Oid = 21 T_int2vector Oid = 22 T_int4 Oid = 23 T_regproc Oid = 24 T_text Oid = 25 T_oid Oid = 26 T_tid Oid = 27 T_xid Oid = 28 T_cid Oid = 29 T_oidvector Oid = 30 T_pg_ddl_command Oid = 32 T_pg_type Oid = 71 T_pg_attribute Oid = 75 T_pg_proc Oid = 81 T_pg_class Oid = 83 T_json Oid = 114 T_xml Oid = 142 T__xml Oid = 143 T_pg_node_tree Oid = 194 T__json Oid = 199 T_smgr Oid = 210 T_index_am_handler Oid = 325 T_point Oid = 600 T_lseg Oid = 601 T_path Oid = 602 T_box Oid = 603 T_polygon Oid = 604 T_line Oid = 628 T__line Oid = 629 T_cidr Oid = 650 T__cidr Oid = 651 T_float4 Oid = 700 T_float8 Oid = 701 T_abstime Oid = 702 T_reltime Oid = 703 T_tinterval Oid = 704 T_unknown Oid = 705 T_circle Oid = 718 T__circle Oid = 719 T_money Oid = 790 T__money Oid = 791 T_macaddr Oid = 829 T_inet Oid = 869 T__bool Oid = 1000 T__bytea Oid = 1001 T__char Oid = 1002 T__name Oid = 1003 T__int2 Oid = 1005 T__int2vector Oid = 1006 T__int4 Oid = 1007 T__regproc Oid = 1008 T__text Oid = 1009 T__tid Oid = 1010 T__xid Oid = 1011 T__cid Oid = 1012 T__oidvector Oid = 1013 T__bpchar Oid = 1014 T__varchar Oid = 1015 T__int8 Oid = 1016 T__point Oid = 1017 T__lseg Oid = 1018 T__path Oid = 1019 T__box Oid = 1020 T__float4 Oid = 1021 T__float8 Oid = 1022 T__abstime Oid = 1023 T__reltime Oid = 1024 T__tinterval Oid = 1025 T__polygon Oid = 1027 T__oid Oid = 1028 T_aclitem Oid = 1033 T__aclitem Oid = 1034 T__macaddr Oid = 1040 T__inet Oid = 1041 T_bpchar Oid = 1042 T_varchar Oid = 1043 T_date Oid = 1082 T_time Oid = 1083 T_timestamp Oid = 1114 T__timestamp Oid = 1115 T__date Oid = 1182 T__time Oid = 1183 T_timestamptz Oid = 1184 T__timestamptz Oid = 1185 T_interval Oid = 1186 T__interval Oid = 1187 T__numeric Oid = 1231 T_pg_database Oid = 1248 T__cstring Oid = 1263 T_timetz Oid = 1266 T__timetz Oid = 1270 T_bit Oid = 1560 T__bit Oid = 1561 T_varbit Oid = 1562 T__varbit Oid = 1563 T_numeric Oid = 1700 T_refcursor Oid = 1790 T__refcursor Oid = 2201 T_regprocedure Oid = 2202 T_regoper Oid = 2203 T_regoperator Oid = 2204 T_regclass Oid = 2205 T_regtype Oid = 2206 T__regprocedure Oid = 2207 T__regoper Oid = 2208 T__regoperator Oid = 2209 T__regclass Oid = 2210 T__regtype Oid = 2211 T_record Oid = 2249 T_cstring Oid = 2275 T_any Oid = 2276 T_anyarray Oid = 2277 T_void Oid = 2278 T_trigger Oid = 2279 T_language_handler Oid = 2280 T_internal Oid = 2281 T_opaque Oid = 2282 T_anyelement Oid = 2283 T__record Oid = 2287 T_anynonarray Oid = 2776 T_pg_authid Oid = 2842 T_pg_auth_members Oid = 2843 T__txid_snapshot Oid = 2949 T_uuid Oid = 2950 T__uuid Oid = 2951 T_txid_snapshot Oid = 2970 T_fdw_handler Oid = 3115 T_pg_lsn Oid = 3220 T__pg_lsn Oid = 3221 T_tsm_handler Oid = 3310 T_anyenum Oid = 3500 T_tsvector Oid = 3614 T_tsquery Oid = 3615 T_gtsvector Oid = 3642 T__tsvector Oid = 3643 T__gtsvector Oid = 3644 T__tsquery Oid = 3645 T_regconfig Oid = 3734 T__regconfig Oid = 3735 T_regdictionary Oid = 3769 T__regdictionary Oid = 3770 T_jsonb Oid = 3802 T__jsonb Oid = 3807 T_anyrange Oid = 3831 T_event_trigger Oid = 3838 T_int4range Oid = 3904 T__int4range Oid = 3905 T_numrange Oid = 3906 T__numrange Oid = 3907 T_tsrange Oid = 3908 T__tsrange Oid = 3909 T_tstzrange Oid = 3910 T__tstzrange Oid = 3911 T_daterange Oid = 3912 T__daterange Oid = 3913 T_int8range Oid = 3926 T__int8range Oid = 3927 T_pg_shseclabel Oid = 4066 T_regnamespace Oid = 4089 T__regnamespace Oid = 4090 T_regrole Oid = 4096 T__regrole Oid = 4097 )
type StringArray ¶
type StringArray []string
StringArray represents a one-dimensional array of the PostgreSQL character types.
func (*StringArray) Scan ¶
func (a *StringArray) Scan(src interface{}) error
Scan implements the sql.Scanner interface.