types

package
v3.0.0-rc8+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Array

func Array(a interface{}) interface {
	driver.Valuer
	sql.Scanner
}

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

func EnableInfinityTs(negative time.Time, positive time.Time)

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

func FormatTimestamp(t time.Time) []byte

FormatTimestamp formats t into Postgres' text format for timestamps.

func ParseTimestamp

func ParseTimestamp(currentLocation *time.Location, str string) (time.Time, error)

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.

func (*BoolArray) Randomize

func (a *BoolArray) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*BoolArray) Scan

func (a *BoolArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (BoolArray) Value

func (a BoolArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Byte

type Byte byte

Byte is an alias for byte. Byte implements Marshal and Unmarshal.

func (Byte) MarshalJSON

func (b Byte) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of b.

func (*Byte) Randomize

func (b *Byte) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*Byte) Scan

func (b *Byte) Scan(src interface{}) error

Scan stores the src in *b.

func (Byte) String

func (b Byte) String() string

String output your byte.

func (*Byte) UnmarshalJSON

func (b *Byte) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *b to a copy of data.

func (Byte) Value

func (b Byte) Value() (driver.Value, error)

Value returns b as a driver.Value.

type BytesArray

type BytesArray [][]byte

BytesArray represents a one-dimensional array of the PostgreSQL bytea type.

func (*BytesArray) Randomize

func (a *BytesArray) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*BytesArray) Scan

func (a *BytesArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (BytesArray) Value

func (a BytesArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface. It uses the "hex" format which is only supported on PostgreSQL 9.0 or newer.

type Decimal

type Decimal struct {
	*decimal.Big
}

Decimal is a DECIMAL in sql. Its zero value is valid for use with both Value and Scan.

Although decimal can represent NaN and Infinity it will return an error if an attempt to store these values in the database is made.

Because it cannot be nil, when Big is nil Value() will return "0" It will error if an attempt to Scan() a "null" value into it.

func NewDecimal

func NewDecimal(d *decimal.Big) Decimal

NewDecimal creates a new decimal from a decimal

func (*Decimal) Randomize

func (d *Decimal) Randomize(s *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize implements sqlboiler's randomize interface

func (*Decimal) Scan

func (d *Decimal) Scan(val interface{}) error

Scan implements sql.Scanner.

func (Decimal) Value

func (d Decimal) Value() (driver.Value, error)

Value implements driver.Valuer.

type DecimalArray

type DecimalArray []Decimal

DecimalArray represents a one-dimensional array of the decimal type.

func (*DecimalArray) Randomize

func (a *DecimalArray) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*DecimalArray) Scan

func (a *DecimalArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (DecimalArray) Value

func (a DecimalArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Float64Array

type Float64Array []float64

Float64Array represents a one-dimensional array of the PostgreSQL double precision type.

func (*Float64Array) Randomize

func (a *Float64Array) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*Float64Array) Scan

func (a *Float64Array) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Float64Array) Value

func (a Float64Array) Value() (driver.Value, error)

Value implements the driver.Valuer 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.

func (GenericArray) Value

func (a GenericArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type HStore

type HStore map[string]sql.NullString

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

func (*HStore) Randomize

func (h *HStore) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*HStore) Scan

func (h *HStore) Scan(value interface{}) 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) 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 Int64Array

type Int64Array []int64

Int64Array represents a one-dimensional array of the PostgreSQL integer types.

func (*Int64Array) Randomize

func (a *Int64Array) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*Int64Array) Scan

func (a *Int64Array) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Int64Array) Value

func (a Int64Array) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type JSON

type JSON json.RawMessage

JSON is an alias for json.RawMessage, which is a []byte underneath. JSON implements Marshal and Unmarshal.

func (*JSON) Marshal

func (j *JSON) Marshal(obj interface{}) error

Marshal obj into your JSON variable.

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON returns j as the JSON encoding of j.

func (*JSON) Randomize

func (j *JSON) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*JSON) Scan

func (j *JSON) Scan(src interface{}) error

Scan stores the src in *j.

func (JSON) String

func (j JSON) String() string

String output your JSON.

func (JSON) Unmarshal

func (j JSON) Unmarshal(dest interface{}) error

Unmarshal your JSON variable into dest.

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *j to a copy of data.

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value returns j as a value. Unmarshal into RawMessage for validation.

type NullDecimal

type NullDecimal struct {
	*decimal.Big
}

NullDecimal is the same as Decimal, but allows the Big pointer to be nil. See docmentation for Decimal for more details.

When going into a database, if Big is nil it's value will be "null".

func NewNullDecimal

func NewNullDecimal(d *decimal.Big) NullDecimal

NewNullDecimal creates a new null decimal from a decimal

func (*NullDecimal) Randomize

func (n *NullDecimal) Randomize(s *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize implements sqlboiler's randomize interface

func (*NullDecimal) Scan

func (n *NullDecimal) Scan(val interface{}) error

Scan implements sql.Scanner.

func (NullDecimal) Value

func (n NullDecimal) Value() (driver.Value, error)

Value implements driver.Valuer.

type StringArray

type StringArray []string

StringArray represents a one-dimensional array of the PostgreSQL character types.

func (*StringArray) Randomize

func (a *StringArray) Randomize(seed *randomize.Seed, fieldType string, shouldBeNull bool)

Randomize for sqlboiler

func (*StringArray) Scan

func (a *StringArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (StringArray) Value

func (a StringArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Directories

Path Synopsis
Package pgeo implements geometric types for Postgres
Package pgeo implements geometric types for Postgres

Jump to

Keyboard shortcuts

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