Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Bool = NewOpaqueType("bool") Boolp = NewOpaqueType("*bool") Int = NewOpaqueType("int") Intp = NewOpaqueType("*int") IntSlice = NewOpaqueType("[]int") IntpSlice = NewOpaqueType("[]*int") Int16 = NewOpaqueType("int16") Int16p = NewOpaqueType("*int16") Int16Slice = NewOpaqueType("[]int16") Int16pSlice = NewOpaqueType("[]*int16") Int32 = NewOpaqueType("int32") Int32p = NewOpaqueType("*int32") Int32Slice = NewOpaqueType("[]int32") Int32pSlice = NewOpaqueType("[]*int32") Int64 = NewOpaqueType("int64") Int64p = NewOpaqueType("*int64") Int64Slice = NewOpaqueType("[]int64") Int64pSlice = NewOpaqueType("[]*int64") Uint = NewOpaqueType("uint") UintSlice = NewOpaqueType("[]uint") Uint16 = NewOpaqueType("uint16") Uint16Slice = NewOpaqueType("[]uint16") Uint32 = NewOpaqueType("uint32") Uint32Slice = NewOpaqueType("[]uint32") Uint64 = NewOpaqueType("uint64") Uint64Slice = NewOpaqueType("[]uint64") String = NewOpaqueType("string") Stringp = NewOpaqueType("*string") StringSlice = NewOpaqueType("[]string") StringpSlice = NewOpaqueType("[]*string") Float32 = NewOpaqueType("float32") Float32p = NewOpaqueType("*float32") Float32Slice = NewOpaqueType("[]float32") Float32pSlice = NewOpaqueType("[]*float32") Float64 = NewOpaqueType("float64") Float64p = NewOpaqueType("*float64") Float64Slice = NewOpaqueType("[]float64") Float64pSlice = NewOpaqueType("[]*float64") ByteSlice = NewOpaqueType("[]byte") )
Native go types are not prefixed.
var ( PgBool = NewOpaqueType("github.com/jackc/pgtype.Bool") PgQChar = NewOpaqueType("github.com/jackc/pgtype.QChar") PgName = NewOpaqueType("github.com/jackc/pgtype.Name") PgInt8 = NewOpaqueType("github.com/jackc/pgtype.Int8") PgInt2 = NewOpaqueType("github.com/jackc/pgtype.Int2") PgInt4 = NewOpaqueType("github.com/jackc/pgtype.Int4") PgText = NewOpaqueType("github.com/jackc/pgtype.Text") PgBytea = NewOpaqueType("github.com/jackc/pgtype.Bytea") PgOID = NewOpaqueType("github.com/jackc/pgtype.OID") PgTID = NewOpaqueType("github.com/jackc/pgtype.TID") PgXID = NewOpaqueType("github.com/jackc/pgtype.XID") PgCID = NewOpaqueType("github.com/jackc/pgtype.CID") PgJSON = NewOpaqueType("github.com/jackc/pgtype.JSON") PgPoint = NewOpaqueType("github.com/jackc/pgtype.Point") PgLseg = NewOpaqueType("github.com/jackc/pgtype.Lseg") PgPath = NewOpaqueType("github.com/jackc/pgtype.Path") PgBox = NewOpaqueType("github.com/jackc/pgtype.Box") PgPolygon = NewOpaqueType("github.com/jackc/pgtype.Polygon") PgLine = NewOpaqueType("github.com/jackc/pgtype.Line") PgCIDR = NewOpaqueType("github.com/jackc/pgtype.CIDR") PgCIDRArray = NewOpaqueType("github.com/jackc/pgtype.CIDRArray") PgFloat4 = NewOpaqueType("github.com/jackc/pgtype.Float4") PgFloat8 = NewOpaqueType("github.com/jackc/pgtype.Float8") PgUnknown = NewOpaqueType("github.com/jackc/pgtype.Unknown") PgCircle = NewOpaqueType("github.com/jackc/pgtype.Circle") PgMacaddr = NewOpaqueType("github.com/jackc/pgtype.Macaddr") PgInet = NewOpaqueType("github.com/jackc/pgtype.Inet") PgBoolArray = NewOpaqueType("github.com/jackc/pgtype.BoolArray") PgByteaArray = NewOpaqueType("github.com/jackc/pgtype.ByteaArray") PgInt2Array = NewOpaqueType("github.com/jackc/pgtype.Int2Array") PgInt4Array = NewOpaqueType("github.com/jackc/pgtype.Int4Array") PgTextArray = NewOpaqueType("github.com/jackc/pgtype.TextArray") PgBPCharArray = NewOpaqueType("github.com/jackc/pgtype.BPCharArray") PgVarcharArray = NewOpaqueType("github.com/jackc/pgtype.VarcharArray") PgInt8Array = NewOpaqueType("github.com/jackc/pgtype.Int8Array") PgFloat4Array = NewOpaqueType("github.com/jackc/pgtype.Float4Array") PgFloat8Array = NewOpaqueType("github.com/jackc/pgtype.Float8Array") PgACLItem = NewOpaqueType("github.com/jackc/pgtype.ACLItem") PgACLItemArray = NewOpaqueType("github.com/jackc/pgtype.ACLItemArray") PgInetArray = NewOpaqueType("github.com/jackc/pgtype.InetArray") PgMacaddrArray = NewOpaqueType("github.com/jackc/pgtype.MacaddrArray") PgBPChar = NewOpaqueType("github.com/jackc/pgtype.BPChar") PgVarchar = NewOpaqueType("github.com/jackc/pgtype.Varchar") PgDate = NewOpaqueType("github.com/jackc/pgtype.Date") PgTime = NewOpaqueType("github.com/jackc/pgtype.Time") PgTimestamp = NewOpaqueType("github.com/jackc/pgtype.Timestamp") PgTimestampArray = NewOpaqueType("github.com/jackc/pgtype.TimestampArray") PgDateArray = NewOpaqueType("github.com/jackc/pgtype.DateArray") PgTimestamptz = NewOpaqueType("github.com/jackc/pgtype.Timestamptz") PgTimestamptzArray = NewOpaqueType("github.com/jackc/pgtype.TimestamptzArray") PgInterval = NewOpaqueType("github.com/jackc/pgtype.Interval") PgNumericArray = NewOpaqueType("github.com/jackc/pgtype.NumericArray") PgBit = NewOpaqueType("github.com/jackc/pgtype.Bit") PgVarbit = NewOpaqueType("github.com/jackc/pgtype.Varbit") PgVoid = VoidType{} PgNumeric = NewOpaqueType("github.com/jackc/pgtype.Numeric") PgRecord = NewOpaqueType("github.com/jackc/pgtype.Record") PgUUID = NewOpaqueType("github.com/jackc/pgtype.UUID") PgUUIDArray = NewOpaqueType("github.com/jackc/pgtype.UUIDArray") PgJSONB = NewOpaqueType("github.com/jackc/pgtype.JSONB") PgJSONBArray = NewOpaqueType("github.com/jackc/pgtype.JSONBArray") PgInt4range = NewOpaqueType("github.com/jackc/pgtype.Int4range") PgNumrange = NewOpaqueType("github.com/jackc/pgtype.Numrange") PgTsrange = NewOpaqueType("github.com/jackc/pgtype.Tsrange") PgTstzrange = NewOpaqueType("github.com/jackc/pgtype.Tstzrange") PgDaterange = NewOpaqueType("github.com/jackc/pgtype.Daterange") PgInt8range = NewOpaqueType("github.com/jackc/pgtype.Int8range") )
pgtype types prefixed with "pg".
Functions ¶
func ChooseFallbackName ¶
func ExtractShortPackage ¶
ExtractShortPackage gets the last part of a package path like "generate" in "github.com/djsavvy/pggen/generate".
func HasArrayType ¶
HasArrayType returns true if t or any of t's descendants (for array and composite types) is an array type.
func HasCompositeType ¶
HasCompositeType returns true if t or any of t's descendants (for array and composite types) is a composite type.
Types ¶
type ArrayType ¶
type ArrayType struct { PgArray pg.ArrayType // original Postgres array type PkgPath string // fully qualified package path, like "github.com/djsavvy/pggen" Pkg string // last part of the package path like "pggen" or empty for builtin types Name string // name of Go slice type in UpperCamelCase with leading brackets, like "[]Foo" Elem Type // base type of the slice, like int for []int }
ArrayType is a Go slice type.
func NewArrayType ¶
func (ArrayType) QualifyRel ¶
type CompositeType ¶
type CompositeType struct { PgComposite pg.CompositeType // original Postgres composite type PkgPath string Pkg string Name string // Go-style type name in UpperCamelCase FieldNames []string // Go-style child names in UpperCamelCase FieldTypes []Type }
CompositeType is a struct type that represents a Postgres composite type, typically from a table.
func (CompositeType) BaseName ¶
func (c CompositeType) BaseName() string
func (CompositeType) Import ¶
func (c CompositeType) Import() string
func (CompositeType) Package ¶
func (c CompositeType) Package() string
func (CompositeType) PgType ¶
func (c CompositeType) PgType() pg.Type
func (CompositeType) QualifyRel ¶
func (c CompositeType) QualifyRel(pkgPath string) string
type EnumType ¶
type EnumType struct { PgEnum pg.EnumType // the original Postgres enum type PkgPath string Pkg string Name string // Labels of the Postgres enum formatted as Go identifiers ordered in the // same order as in Postgres. Labels []string // The string constant associated with a label. Labels[i] represents // Values[i]. Values []string }
EnumType is a string type with constant values that maps to the labels of a Postgres enum.
func NewEnumType ¶
func (EnumType) QualifyRel ¶
type OpaqueType ¶
type OpaqueType struct { PgTyp pg.Type // original Postgres type PkgPath string Pkg string Name string }
OpaqueType is a type where only the name is known, as with a user-provided custom type.
func NewOpaqueType ¶
func NewOpaqueType(qualType string) OpaqueType
NewOpaqueType creates a OpaqueType by parsing the fully qualified Go type like "github.com/djsavvy/pggen.GenerateOpts", or a builtin type like "string". Supports slice and pointer types:
- []int
- []*int
- *example.com/foo.Qux
- []*example.com/foo.Qux
func (OpaqueType) BaseName ¶
func (o OpaqueType) BaseName() string
func (OpaqueType) Import ¶
func (o OpaqueType) Import() string
func (OpaqueType) Package ¶
func (o OpaqueType) Package() string
func (OpaqueType) PgType ¶
func (o OpaqueType) PgType() pg.Type
func (OpaqueType) QualifyRel ¶
func (o OpaqueType) QualifyRel(pkgPath string) string
type Type ¶
type Type interface { // QualifyRel qualifies the type relative to another pkgPath. If this type's // package path is the same, return the BaseName. Otherwise, qualify the type // with Package. QualifyRel(pkgPath string) string // Import returns the full package path, like "github.com/djsavvy/pggen/foo". // Empty for builtin types. Import() string // Package returns the last part of the package path like "qux" in the package // "github.com/djsavvy/pggen/qux". Empty for builtin types. Package() string // BaseName returns the base name of the type, like "Foo" in: // type Foo int BaseName() string // PgType returns the Postgres type this type represents, or nil if not known. PgType() pg.Type }
Type is a Go type.
func FindKnownTypeNonNullable ¶
FindKnownTypeNonNullable returns the non-nullable type like string, if known, for a Postgres OID. Falls back to the nullable type and pgNative type. If there is no known type for the OID, returns nil.
func FindKnownTypeNullable ¶
FindKnownTypeNullable returns the nullable type, like *string, if known, for a Postgres OID. Falls back to the pgNative type. If there is no known type for the OID, returns nil.
type VoidType ¶
type VoidType struct{}
VoidType is a placeholder type that should never appear in output. We need a placeholder to scan pgx rows but we ultimately ignore the results in the return values.