pgdesign v0.26.0 /internal/typeinfo
On this page

Package typeinfo provides a structured PostgreSQL type representation, parsing raw type strings into base plus parameters and rebuilding SQL type strings.

#internal/typeinfo

#internal/typeinfo

Package typeinfo provides structured PostgreSQL type representation. It parses raw type strings (from TOML schemas, format_type() output, etc.) into a normalized struct with separated base type and parameters, and can reconstruct the SQL type string from the struct.

#Params

Go go
type Params struct

Params holds parsed type parameters. For known types, named fields are populated; for unknown/extension types, only RawModifier is set.

#Type

Go go
type Type struct

Type represents a parsed PostgreSQL type with its canonical base name and optional parameters.

#Parse

Go go
func Parse(raw string) Type

Parse parses a raw PostgreSQL type string into a structured Type. It normalizes aliases, extracts parameters, and handles multi-word types with interior parameters (e.g., "timestamp(3) with time zone"). DomainName is NEVER set by Parse.

#Reconstruct

Go go
func Reconstruct(t Type) string

Reconstruct rebuilds a SQL type string from a Type struct. If DomainName is set, it is returned directly (domain-backed columns use the domain name in DDL). Otherwise, the type is reconstructed from Base and Params.

#T

Go go
func T(base string) Type

T is a concise constructor for test literals. It returns Type{Base: base} with all params at zero values.

#MustParse

Go go
func MustParse(raw string) Type

MustParse parses a raw type string and panics if the input is empty. Intended for test setup only.

#Type.Equal

Go go
func (t Type) Equal(other Type) bool

Equal returns true if two Types have the same Base, DomainName, and Params (deep comparison of pointer fields).

Search