pgdesign v0.26.0 /internal/semtype
On this page

Package semtype implements the semantic type system for pgdesign, mapping user-defined enums, scalar domains, composite types, and state machines.

#internal/semtype

#internal/semtype

Package semtype implements the semantic type system for pgdesign, mapping user-defined enums, scalar domains, composite types, and state machines.

#KindScalar

Go go
const KindScalar       Kind = iota

#KindEnum

Go go
const KindEnum         Kind = iota

#KindComposite

Go go
const KindComposite    Kind = iota

#KindStateMachine

Go go
const KindStateMachine Kind = iota

#Kind

Go go
type Kind int

Kind represents the kind of a type definition.

#CompositeField

Go go
type CompositeField struct

CompositeField represents a single field in a composite type.

#SMStateDef

Go go
type SMStateDef struct

SMStateDef represents a state in a state machine type definition.

#SMTransitionDef

Go go
type SMTransitionDef struct

SMTransitionDef represents a transition in a state machine type definition.

#TypeDef

Go go
type TypeDef struct

TypeDef defines a semantic type with its PostgreSQL mapping and constraints.

#Registry

Go go
type Registry struct

Registry holds named TypeDefs with thread-safe read access.

#UserSMState

Go go
type UserSMState struct

UserSMState represents a state in a user-defined state machine type.

#UserSMTransition

Go go
type UserSMTransition struct

UserSMTransition represents a transition in a user-defined state machine type.

#UserTypeDef

Go go
type UserTypeDef struct

UserTypeDef represents a user-defined type loaded from configuration.

#ResolvedColumn

Go go
type ResolvedColumn struct

ResolvedColumn represents the final resolved attributes for a column after applying type defaults and column-level overrides.

#NewBuiltinRegistry

Go go
func NewBuiltinRegistry() *Registry

NewBuiltinRegistry creates a Registry pre-populated with all builtin types.

#NewRegistry

Go go
func NewRegistry() *Registry

NewRegistry creates an empty Registry.

#Kind.String

Go go
func (k Kind) String() string

#Registry.AddExtensionTypes

Go go
func (r *Registry) AddExtensionTypes(typeNames []string)

AddExtensionTypes registers extension-provided type names as valid base types for scalar definitions. This allows extensions like pgvector to provide types (e.g., "vector") that pass the allowlist check without mutating global state.

#Registry.Register

Go go
func (r *Registry) Register(td *TypeDef) error

Register adds a type definition to the registry. Decision tree: 1. Name not in registry: register normally. 2. Name exists + identical definition: accept silently (idempotent for multi-file schemas). 3. Name exists + different definition + existing is builtin: allow shadowing if sealed fields (Kind, BaseType.Base) match. Emits I101 on success, E114 on sealed field mismatch. 4. Name exists + different definition + existing is not builtin: E105 error.

#Registry.ShadowDiags

Go go
func (r *Registry) ShadowDiags() diagnostic.Diagnostics

ShadowDiags returns diagnostics accumulated during Register() calls for builtin shadowing (I101 info, E114 errors). Call after LoadUserTypes().

#Registry.IsBuiltin

Go go
func (r *Registry) IsBuiltin(name string) bool

IsBuiltin returns true if the named type exists in the registry with Source "builtin".

#Registry.BuiltinNames

Go go
func (r *Registry) BuiltinNames() []string

BuiltinNames returns the names of all registered builtin types (Source "builtin"), sorted for deterministic iteration. It lets generators and tooling draw column types from the real registry rather than a hardcoded copy that could silently drift when the builtin set changes.

#Registry.Resolve

Go go
func (r *Registry) Resolve(name string) (*TypeDef, error)

Resolve looks up a type by name. Returns an error if the type is not found.

#Registry.StateMachineTypes

Go go
func (r *Registry) StateMachineTypes() []*TypeDef

StateMachineTypes returns all registered state machine type definitions, sorted by name for deterministic output.

#Registry.LoadUserTypes

Go go
func (r *Registry) LoadUserTypes(types []UserTypeDef) diagnostic.Diagnostics

LoadUserTypes validates and registers user-defined types into the registry. Types with extends references are topologically sorted before processing so that parent types are always loaded before their children. Returns diagnostics for any validation failures.

#Registry.ResolveColumn

Go go
func (r *Registry) ResolveColumn(typeName string, nullable *bool, defaultOverride *string, defaultExprOverride *string, array *bool) (*ResolvedColumn, error)

ResolveColumn resolves a column's final attributes by looking up the type and applying column-level overrides.

Search