pgtypes

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Package pgtypes provides GORM-compatible custom PostgreSQL types.

Index

Constants

This section is empty.

Variables

View Source
var PgTypeMap = map[string]string{

	"text[]":                        "pgtypes.StringArray",
	"varchar[]":                     "pgtypes.StringArray",
	"integer[]":                     "pgtypes.Int32Array",
	"int4[]":                        "pgtypes.Int32Array",
	"int8[]":                        "pgtypes.Int64Array",
	"bigint[]":                      "pgtypes.Int64Array",
	"bool[]":                        "pgtypes.BoolArray",
	"boolean[]":                     "pgtypes.BoolArray",
	"uuid[]":                        "pgtypes.UUIDArray",
	"float8[]":                      "pgtypes.Float64Array",
	"double precision[]":            "pgtypes.Float64Array",
	"timestamptz[]":                 "pgtypes.TimeArray",
	"timestamp[]":                   "pgtypes.TimeArray",
	"timestamp with time zone[]":    "pgtypes.TimeArray",
	"timestamp without time zone[]": "pgtypes.TimeArray",

	"interval":   "pgtypes.Duration",
	"interval[]": "pgtypes.DurationArray",

	"bool": "bool",

	"int2": "int16",
	"int4": "int32",
	"int8": "int64",

	"float4": "float32",
	"float8": "float64",

	"numeric": "string",

	"text":    "string",
	"varchar": "string",
	"bpchar":  "string",
	"char":    "string",
	"name":    "string",

	"bytea": "[]byte",

	"uuid": "uuid.UUID",

	"json":  "json.RawMessage",
	"jsonb": "json.RawMessage",

	"xml": "string",

	"date":        "time.Time",
	"timestamp":   "time.Time",
	"timestamptz": "time.Time",

	"time":   "string",
	"timetz": "string",

	"inet":     "net.IPNet",
	"cidr":     "net.IPNet",
	"macaddr":  "net.HardwareAddr",
	"macaddr8": "net.HardwareAddr",

	"bit":    "string",
	"varbit": "string",

	"tsvector": "string",
	"tsquery":  "string",

	"vector":      "string",
	"vector(384)": "string",
	"halfvec":     "string",
	"sparsevec":   "string",

	"oid":           "uint32",
	"regclass":      "uint32",
	"regproc":       "uint32",
	"regprocedure":  "uint32",
	"regtype":       "uint32",
	"regrole":       "uint32",
	"regnamespace":  "uint32",
	"regconfig":     "uint32",
	"regdictionary": "uint32",

	"pg_lsn":        "string",
	"txid_snapshot": "string",

	"point":   "string",
	"line":    "string",
	"lseg":    "string",
	"box":     "string",
	"path":    "string",
	"polygon": "string",
	"circle":  "string",

	"int4range": "string",
	"int8range": "string",
	"numrange":  "string",
	"tsrange":   "string",
	"tstzrange": "string",
	"daterange": "string",

	"int4multirange": "string",
	"int8multirange": "string",
	"nummultirange":  "string",
	"tsmultirange":   "string",
	"tstzmultirange": "string",
	"datemultirange": "string",

	"money": "string",
}

Functions

This section is empty.

Types

type BoolArray

type BoolArray []bool

BoolArray is a slice of booleans that supports PostgreSQL's boolean array type.

func (BoolArray) Append

func (a BoolArray) Append(vals ...bool) BoolArray

Append returns a new BoolArray with the given values appended.

func (BoolArray) AsSlice

func (a BoolArray) AsSlice() []bool

AsSlice converts the BoolArray to a bool slice.

func (BoolArray) Contains

func (a BoolArray) Contains(val bool) bool

Contains returns true if the BoolArray contains the given value.

func (BoolArray) Equals

func (a BoolArray) Equals(b BoolArray) bool

Equals returns true if the BoolArray is equal to another BoolArray.

func (BoolArray) Filter

func (a BoolArray) Filter(f func(bool) bool) BoolArray

Filter returns a new BoolArray containing only elements that satisfy the given predicate.

func (BoolArray) FromSlice

func (BoolArray) FromSlice(s []bool) BoolArray

FromSlice converts a bool slice to a BoolArray.

func (BoolArray) GormDBDataType

func (BoolArray) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType implements the gorm.DBDataTypeInterface.

func (BoolArray) GormDataType

func (BoolArray) GormDataType() string

GormDataType implements the gorm.DataTypeInterface.

func (BoolArray) IndexOf

func (a BoolArray) IndexOf(val bool) int

IndexOf returns the index of the first occurrence of the given value, or -1 if not found.

func (BoolArray) IsEmpty

func (a BoolArray) IsEmpty() bool

IsEmpty returns true if the BoolArray is empty.

func (BoolArray) Len

func (a BoolArray) Len() int

func (BoolArray) Less

func (a BoolArray) Less(i, j int) bool

func (BoolArray) MarshalJSON

func (a BoolArray) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (BoolArray) MarshalText

func (a BoolArray) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*BoolArray) Scan

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

Scan implements the sql.Scanner interface.

func (BoolArray) String

func (a BoolArray) String() string

func (BoolArray) Swap

func (a BoolArray) Swap(i, j int)

func (BoolArray) Unique

func (a BoolArray) Unique() BoolArray

Unique returns a new BoolArray with duplicate values removed.

func (*BoolArray) UnmarshalJSON

func (a *BoolArray) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*BoolArray) UnmarshalText

func (a *BoolArray) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (BoolArray) Value

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

Value implements the driver.Valuer interface.

type Duration

type Duration struct {
	time.Duration
}

Duration is a wrapper around time.Duration that supports PostgreSQL's interval type.

func FromDuration

func FromDuration(d time.Duration) Duration

FromDuration converts a time.Duration to a Duration.

func (Duration) AsDuration

func (d Duration) AsDuration() time.Duration

AsDuration converts the Duration to a time.Duration.

func (Duration) Equals

func (d Duration) Equals(other Duration) bool

Equals returns true if the Duration is equal to another Duration.

func (Duration) GormDBDataType

func (Duration) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType implements the gorm.DBDataTypeInterface.

func (Duration) GormDataType

func (Duration) GormDataType() string

GormDataType implements the gorm.DataTypeInterface.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Duration) Scan

func (d *Duration) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Duration) Value

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

Value implements the driver.Valuer interface.

type DurationArray

type DurationArray []Duration

DurationArray is a slice of Durations that supports PostgreSQL's interval array type.

func (DurationArray) Append

func (a DurationArray) Append(vals ...time.Duration) DurationArray

Append returns a new DurationArray with the given values appended.

func (DurationArray) AsSlice

func (a DurationArray) AsSlice() []time.Duration

AsSlice converts the DurationArray to a time.Duration slice.

func (DurationArray) Contains

func (a DurationArray) Contains(val time.Duration) bool

Contains returns true if the DurationArray contains the given value.

func (DurationArray) Equals

func (a DurationArray) Equals(b DurationArray) bool

Equals returns true if the DurationArray is equal to another DurationArray.

func (DurationArray) Filter

func (a DurationArray) Filter(f func(time.Duration) bool) DurationArray

Filter returns a new DurationArray containing only elements that satisfy the given predicate.

func (DurationArray) FromSlice

func (DurationArray) FromSlice(s []time.Duration) DurationArray

FromSlice converts a time.Duration slice to a DurationArray.

func (DurationArray) GormDBDataType

func (DurationArray) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType implements the gorm.DBDataTypeInterface.

func (DurationArray) GormDataType

func (DurationArray) GormDataType() string

GormDataType implements the gorm.DataTypeInterface.

func (DurationArray) IndexOf

func (a DurationArray) IndexOf(val time.Duration) int

IndexOf returns the index of the first occurrence of the given value, or -1 if not found.

func (DurationArray) IsEmpty

func (a DurationArray) IsEmpty() bool

IsEmpty returns true if the DurationArray is empty.

func (DurationArray) Len

func (a DurationArray) Len() int

func (DurationArray) Less

func (a DurationArray) Less(i, j int) bool

func (DurationArray) MarshalJSON

func (a DurationArray) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (DurationArray) MarshalText

func (a DurationArray) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*DurationArray) Scan

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

Scan implements the sql.Scanner interface.

func (DurationArray) String

func (a DurationArray) String() string

func (DurationArray) Swap

func (a DurationArray) Swap(i, j int)

func (DurationArray) Unique

func (a DurationArray) Unique() DurationArray

Unique returns a new DurationArray with duplicate values removed.

func (*DurationArray) UnmarshalJSON

func (a *DurationArray) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*DurationArray) UnmarshalText

func (a *DurationArray) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (DurationArray) Value

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

Value implements the driver.Valuer interface.

type Float64Array

type Float64Array []float64

func (Float64Array) Append

func (a Float64Array) Append(vals ...float64) Float64Array

func (Float64Array) AsSlice

func (a Float64Array) AsSlice() []float64

func (Float64Array) Contains

func (a Float64Array) Contains(val float64) bool

func (Float64Array) Equals

func (a Float64Array) Equals(b Float64Array) bool

func (Float64Array) Filter

func (a Float64Array) Filter(f func(float64) bool) Float64Array

func (Float64Array) FromSlice

func (Float64Array) FromSlice(s []float64) Float64Array

func (Float64Array) GormDBDataType

func (Float64Array) GormDBDataType(db *gorm.DB, _ *schema.Field) string

func (Float64Array) GormDataType

func (Float64Array) GormDataType() string

func (Float64Array) IndexOf

func (a Float64Array) IndexOf(val float64) int

func (Float64Array) IsEmpty

func (a Float64Array) IsEmpty() bool

func (Float64Array) Len

func (a Float64Array) Len() int

func (Float64Array) Less

func (a Float64Array) Less(i, j int) bool

func (Float64Array) MarshalJSON

func (a Float64Array) MarshalJSON() ([]byte, error)

func (Float64Array) MarshalText

func (a Float64Array) MarshalText() ([]byte, error)

func (*Float64Array) Scan

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

func (Float64Array) String

func (a Float64Array) String() string

func (Float64Array) Swap

func (a Float64Array) Swap(i, j int)

func (Float64Array) Unique

func (a Float64Array) Unique() Float64Array

func (*Float64Array) UnmarshalJSON

func (a *Float64Array) UnmarshalJSON(data []byte) error

func (*Float64Array) UnmarshalText

func (a *Float64Array) UnmarshalText(data []byte) error

func (Float64Array) Value

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

type Int32Array

type Int32Array []int32

func (Int32Array) Append

func (a Int32Array) Append(vals ...int32) Int32Array

func (Int32Array) AsSlice

func (a Int32Array) AsSlice() []int32

func (Int32Array) Contains

func (a Int32Array) Contains(val int32) bool

func (Int32Array) Equals

func (a Int32Array) Equals(b Int32Array) bool

func (Int32Array) Filter

func (a Int32Array) Filter(f func(int32) bool) Int32Array

func (Int32Array) FromSlice

func (Int32Array) FromSlice(s []int32) Int32Array

func (Int32Array) GormDBDataType

func (Int32Array) GormDBDataType(db *gorm.DB, _ *schema.Field) string

func (Int32Array) GormDataType

func (Int32Array) GormDataType() string

func (Int32Array) IndexOf

func (a Int32Array) IndexOf(val int32) int

func (Int32Array) IsEmpty

func (a Int32Array) IsEmpty() bool

func (Int32Array) Len

func (a Int32Array) Len() int

func (Int32Array) Less

func (a Int32Array) Less(i, j int) bool

func (Int32Array) MarshalJSON

func (a Int32Array) MarshalJSON() ([]byte, error)

func (Int32Array) MarshalText

func (a Int32Array) MarshalText() ([]byte, error)

func (*Int32Array) Scan

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

func (Int32Array) String

func (a Int32Array) String() string

func (Int32Array) Swap

func (a Int32Array) Swap(i, j int)

func (Int32Array) Unique

func (a Int32Array) Unique() Int32Array

func (*Int32Array) UnmarshalJSON

func (a *Int32Array) UnmarshalJSON(data []byte) error

func (*Int32Array) UnmarshalText

func (a *Int32Array) UnmarshalText(data []byte) error

func (Int32Array) Value

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

type Int64Array

type Int64Array []int64

func (Int64Array) Append

func (a Int64Array) Append(vals ...int64) Int64Array

func (Int64Array) AsSlice

func (a Int64Array) AsSlice() []int64

func (Int64Array) Contains

func (a Int64Array) Contains(val int64) bool

func (Int64Array) Equals

func (a Int64Array) Equals(b Int64Array) bool

func (Int64Array) Filter

func (a Int64Array) Filter(f func(int64) bool) Int64Array

func (Int64Array) FromSlice

func (Int64Array) FromSlice(s []int64) Int64Array

func (Int64Array) GormDBDataType

func (Int64Array) GormDBDataType(db *gorm.DB, _ *schema.Field) string

func (Int64Array) GormDataType

func (Int64Array) GormDataType() string

func (Int64Array) IndexOf

func (a Int64Array) IndexOf(val int64) int

func (Int64Array) IsEmpty

func (a Int64Array) IsEmpty() bool

func (Int64Array) Len

func (a Int64Array) Len() int

func (Int64Array) Less

func (a Int64Array) Less(i, j int) bool

func (Int64Array) MarshalJSON

func (a Int64Array) MarshalJSON() ([]byte, error)

func (Int64Array) MarshalText

func (a Int64Array) MarshalText() ([]byte, error)

func (*Int64Array) Scan

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

func (Int64Array) String

func (a Int64Array) String() string

func (Int64Array) Swap

func (a Int64Array) Swap(i, j int)

func (Int64Array) Unique

func (a Int64Array) Unique() Int64Array

func (*Int64Array) UnmarshalJSON

func (a *Int64Array) UnmarshalJSON(data []byte) error

func (*Int64Array) UnmarshalText

func (a *Int64Array) UnmarshalText(data []byte) error

func (Int64Array) Value

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

type StringArray

type StringArray []string

func (StringArray) Append

func (a StringArray) Append(vals ...string) StringArray

Append returns a new StringArray with the specified values added

func (StringArray) AsStringSlice

func (a StringArray) AsStringSlice() []string

AsStringSlice returns the StringArray as a []string

func (StringArray) Contains

func (a StringArray) Contains(val string) bool

Contains returns true if the value exists in the array

func (StringArray) Equals

func (a StringArray) Equals(b StringArray) bool

Equals returns true if the other StringArray has the same values in order

func (StringArray) Filter

func (a StringArray) Filter(f func(string) bool) StringArray

Filter returns a new StringArray with elements matching the filter

func (StringArray) FromSlice

func (StringArray) FromSlice(s []string) StringArray

FromSlice creates a new StringArray from a []string

func (StringArray) GormDBDataType

func (StringArray) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType returns the database data type for a specific dialect

func (StringArray) GormDataType

func (StringArray) GormDataType() string

GormDataType returns the general data type

func (StringArray) IndexOf

func (a StringArray) IndexOf(val string) int

IndexOf returns the index of the value, or -1 if not found

func (StringArray) IsEmpty

func (a StringArray) IsEmpty() bool

IsEmpty returns true if the array has no elements

func (StringArray) Len

func (a StringArray) Len() int

Len implements sort.Interface

func (StringArray) Less

func (a StringArray) Less(i, j int) bool

Less implements sort.Interface

func (StringArray) MarshalJSON

func (a StringArray) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (StringArray) MarshalText

func (a StringArray) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*StringArray) Scan

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

func (StringArray) String

func (a StringArray) String() string

String implements fmt.Stringer

func (StringArray) Swap

func (a StringArray) Swap(i, j int)

Swap implements sort.Interface

func (StringArray) Unique

func (a StringArray) Unique() StringArray

Unique returns a new StringArray with duplicate values removed

func (*StringArray) UnmarshalJSON

func (a *StringArray) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

func (*StringArray) UnmarshalText

func (a *StringArray) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler

func (StringArray) Value

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

type TimeArray

type TimeArray []time.Time

func (TimeArray) Append

func (a TimeArray) Append(vals ...time.Time) TimeArray

func (TimeArray) AsSlice

func (a TimeArray) AsSlice() []time.Time

func (TimeArray) Contains

func (a TimeArray) Contains(val time.Time) bool

func (TimeArray) Equals

func (a TimeArray) Equals(b TimeArray) bool

func (TimeArray) Filter

func (a TimeArray) Filter(f func(time.Time) bool) TimeArray

func (TimeArray) FromSlice

func (TimeArray) FromSlice(s []time.Time) TimeArray

func (TimeArray) GormDBDataType

func (TimeArray) GormDBDataType(db *gorm.DB, _ *schema.Field) string

func (TimeArray) GormDataType

func (TimeArray) GormDataType() string

func (TimeArray) IndexOf

func (a TimeArray) IndexOf(val time.Time) int

func (TimeArray) IsEmpty

func (a TimeArray) IsEmpty() bool

func (TimeArray) Len

func (a TimeArray) Len() int

func (TimeArray) Less

func (a TimeArray) Less(i, j int) bool

func (TimeArray) MarshalJSON

func (a TimeArray) MarshalJSON() ([]byte, error)

func (TimeArray) MarshalText

func (a TimeArray) MarshalText() ([]byte, error)

func (*TimeArray) Scan

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

func (TimeArray) String

func (a TimeArray) String() string

func (TimeArray) Swap

func (a TimeArray) Swap(i, j int)

func (TimeArray) Unique

func (a TimeArray) Unique() TimeArray

func (*TimeArray) UnmarshalJSON

func (a *TimeArray) UnmarshalJSON(data []byte) error

func (*TimeArray) UnmarshalText

func (a *TimeArray) UnmarshalText(data []byte) error

func (TimeArray) Value

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

type UUIDArray

type UUIDArray []uuid.UUID

func (UUIDArray) Append

func (a UUIDArray) Append(vals ...uuid.UUID) UUIDArray

func (UUIDArray) AsSlice

func (a UUIDArray) AsSlice() []uuid.UUID

func (UUIDArray) Contains

func (a UUIDArray) Contains(val uuid.UUID) bool

func (UUIDArray) Equals

func (a UUIDArray) Equals(b UUIDArray) bool

func (UUIDArray) Filter

func (a UUIDArray) Filter(f func(uuid.UUID) bool) UUIDArray

func (UUIDArray) FromSlice

func (UUIDArray) FromSlice(s []uuid.UUID) UUIDArray

func (UUIDArray) GormDBDataType

func (UUIDArray) GormDBDataType(db *gorm.DB, _ *schema.Field) string

func (UUIDArray) GormDataType

func (UUIDArray) GormDataType() string

func (UUIDArray) IndexOf

func (a UUIDArray) IndexOf(val uuid.UUID) int

func (UUIDArray) IsEmpty

func (a UUIDArray) IsEmpty() bool

func (UUIDArray) Len

func (a UUIDArray) Len() int

func (UUIDArray) Less

func (a UUIDArray) Less(i, j int) bool

func (UUIDArray) MarshalJSON

func (a UUIDArray) MarshalJSON() ([]byte, error)

func (UUIDArray) MarshalText

func (a UUIDArray) MarshalText() ([]byte, error)

func (*UUIDArray) Scan

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

func (UUIDArray) String

func (a UUIDArray) String() string

func (UUIDArray) Swap

func (a UUIDArray) Swap(i, j int)

func (UUIDArray) Unique

func (a UUIDArray) Unique() UUIDArray

func (*UUIDArray) UnmarshalJSON

func (a *UUIDArray) UnmarshalJSON(data []byte) error

func (*UUIDArray) UnmarshalText

func (a *UUIDArray) UnmarshalText(data []byte) error

func (UUIDArray) Value

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

Jump to

Keyboard shortcuts

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