Documentation
¶
Overview ¶
Package pg provides PostgreSQL type provider for CEL type system integration.
Index ¶
Constants ¶
const ( // MaxConnectionStringLength limits connection string length to prevent // resource exhaustion and align with ODBC standard (1024 chars). // Legitimate PostgreSQL connection strings rarely exceed a few hundred characters. MaxConnectionStringLength = 1000 )
Variables ¶
var ( // ErrInvalidSchema indicates a problem with the provided schema ErrInvalidSchema = errors.New("invalid schema") )
Sentinel errors specific to the pg package
Functions ¶
This section is empty.
Types ¶
type FieldSchema ¶
type FieldSchema struct {
Name string
Type string // PostgreSQL type name (text, integer, boolean, etc.)
Repeated bool // true for arrays
Schema []FieldSchema // for composite types
IsJSON bool // true for json/jsonb types
IsJSONB bool // true for jsonb (vs json)
ElementType string // for arrays: element type name
}
FieldSchema represents a PostgreSQL field type with name, type, and optional nested schema.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema represents a PostgreSQL table schema with O(1) field lookup. It contains a slice of fields for ordered iteration and a map index for fast lookups.
func NewSchema ¶
func NewSchema(fields []FieldSchema) Schema
NewSchema creates a new Schema with field indexing for O(1) lookups. This improves performance for tables with many columns.
func (Schema) Fields ¶
func (s Schema) Fields() []FieldSchema
Fields returns the ordered slice of field schemas. Use this when you need to iterate over fields in their defined order.
type TypeProvider ¶
type TypeProvider interface {
types.Provider
LoadTableSchema(ctx context.Context, tableName string) error
GetSchemas() map[string]Schema
Close()
}
TypeProvider interface for PostgreSQL type providers
func NewTypeProvider ¶
func NewTypeProvider(schemas map[string]Schema) TypeProvider
NewTypeProvider creates a new PostgreSQL type provider with pre-defined schemas
func NewTypeProviderWithConnection ¶
func NewTypeProviderWithConnection(ctx context.Context, connectionString string) (TypeProvider, error)
NewTypeProviderWithConnection creates a new PostgreSQL type provider that can introspect database schemas