Documentation
¶
Overview ¶
Package orm owns the compiler-side integration for the official trb/orm package. The compiler pipeline transports its declarations and IR manifest without depending on database adapters or ORM semantics.
Index ¶
- Constants
- func AggregateOperations() []string
- func AggregateResultType(operation string, column Column) (types.Type, bool)
- func Declarations(input DeclarationInput) (*declaration.Catalog, error)
- func EnumMemberStorageName(name string) string
- func IsGroupableColumn(column Column) bool
- func IsPortableTimeType(value types.Type) bool
- func TableName(model string) string
- func ValidateDeclarationInput(input DeclarationInput) error
- type Adapter
- type Association
- type AssociationKind
- type Column
- type Config
- type DeclarationColumn
- type DeclarationForeignKey
- type DeclarationInput
- type DeclarationSchema
- type DeclarationTable
- type DeclarationUniqueConstraint
- type DependentAction
- type EnumColumn
- type EnumColumnValue
- type ExplainStyle
- type ForeignKey
- type Introspector
- type Manifest
- func (m *Manifest) Augment(program *ir.Program)
- func (m *Manifest) AugmentProgram(program *ir.Program, entrypoint bool)
- func (m *Manifest) ChangesModel(name string) (Model, bool)
- func (m *Manifest) DraftModel(name string) (Model, bool)
- func (m *Manifest) EnumColumnsForModule(module string) []*EnumColumn
- func (m *Manifest) EquivalentForIncrementalLowering(extension ir.Extension) bool
- func (*Manifest) ExtensionName() string
- func (m *Manifest) GroupModel(name string) (Model, Column, bool)
- func (m *Manifest) Model(name string) (Model, bool)
- func (m *Manifest) ModelsForModule(modulePath string) []Model
- func (m *Manifest) QueryModel(name string) (Model, bool)
- func (m *Manifest) RequiresIncrementalRelowering(modulePath string) bool
- func (m *Manifest) ScopeModel(name string) (Model, bool)
- type Model
- func (m Model) Association(name string) (Association, bool)
- func (m Model) BatchKey() (Column, bool)
- func (m Model) ChangesType() string
- func (m Model) Column(name string) (Column, bool)
- func (m Model) DraftType() string
- func (m Model) GroupType(column Column) string
- func (m Model) PrimaryKey() (Column, bool)
- func (m Model) ScopeType() string
- type Operator
- type Predicate
- type Schema
- type Table
- type UniqueConstraint
Constants ¶
const ( PackageName = "trb/orm" TypeProvider = "trb.orm" ProjectProvider = "trb.orm.schema" )
const DeclarationInputProtocolVersion = 1
Variables ¶
This section is empty.
Functions ¶
func AggregateOperations ¶
func AggregateOperations() []string
func AggregateResultType ¶
func Declarations ¶
func Declarations(input DeclarationInput) (*declaration.Catalog, error)
Declarations derives the ORM type-provider catalog from validated, data-only project and schema snapshots. It never receives compiler AST nodes or owns filesystem and database access.
func EnumMemberStorageName ¶ added in v0.2.2
func IsGroupableColumn ¶ added in v0.2.3
func IsPortableTimeType ¶ added in v0.2.3
func ValidateDeclarationInput ¶ added in v0.3.15
func ValidateDeclarationInput(input DeclarationInput) error
Types ¶
type Adapter ¶
type Adapter struct {
Name string
DriverName string
GoDriverImport string
IdentifierMark string
NumberedBinds bool
ExplainStyle ExplainStyle
OffsetNoLimit string
InsertReturning bool
DefaultInsert string
}
Adapter describes the database-specific behavior shared by schema introspection and backend runtime generation.
func AdapterFor ¶
func (Adapter) Placeholder ¶
func (Adapter) QuoteIdentifier ¶
type Association ¶
type AssociationKind ¶
type AssociationKind string
const ( BelongsTo AssociationKind = "belongs_to" HasMany AssociationKind = "has_many" HasOne AssociationKind = "has_one" )
type DeclarationColumn ¶ added in v0.3.15
type DeclarationForeignKey ¶ added in v0.3.15
type DeclarationInput ¶ added in v0.3.15
type DeclarationInput struct {
ProtocolVersion int `json:"protocolVersion"`
Project packageextension.ProjectDeclarationInput `json:"project"`
Schema DeclarationSchema `json:"schema"`
}
DeclarationInput is the complete data-only input consumed by the ORM declaration provider. Project source and schema metadata can cross a JSON boundary without exposing parser nodes, resolver state, database credentials, or filesystem access.
func ExportDeclarationInput ¶ added in v0.3.15
func ExportDeclarationInput(project packageextension.ProjectDeclarationInput, schema *Schema) (DeclarationInput, error)
ExportDeclarationInput copies compiler-owned schema state into the ORM provider boundary and combines it with the generic project declaration snapshot. Database connection details are deliberately omitted.
type DeclarationSchema ¶ added in v0.3.15
type DeclarationSchema struct {
Adapter string `json:"adapter"`
Tables []DeclarationTable `json:"tables,omitempty"`
}
type DeclarationTable ¶ added in v0.3.15
type DeclarationTable struct {
Name string `json:"name"`
Columns []DeclarationColumn `json:"columns,omitempty"`
ForeignKeys []DeclarationForeignKey `json:"foreignKeys,omitempty"`
UniqueConstraints []DeclarationUniqueConstraint `json:"uniqueConstraints,omitempty"`
}
type DeclarationUniqueConstraint ¶ added in v0.3.15
type DeclarationUniqueConstraint struct {
Columns []string `json:"columns"`
}
type DependentAction ¶
type DependentAction string
const ( DependentDestroy DependentAction = "destroy" DependentDelete DependentAction = "delete" DependentNullify DependentAction = "nullify" DependentRestrict DependentAction = "restrict" )
type EnumColumn ¶ added in v0.2.2
type EnumColumn struct {
Name string
ModulePath string
StorageType types.Type
Values []EnumColumnValue
}
func (*EnumColumn) MemberForStorage ¶ added in v0.2.2
func (e *EnumColumn) MemberForStorage(value any) (string, bool)
func (*EnumColumn) StorageValue ¶ added in v0.2.2
func (e *EnumColumn) StorageValue(member string) (any, bool)
type EnumColumnValue ¶ added in v0.2.2
type ExplainStyle ¶
type ExplainStyle string
const ( ExplainSQLite ExplainStyle = "sqlite" ExplainText ExplainStyle = "text" ExplainJSON ExplainStyle = "json" )
type ForeignKey ¶
type Introspector ¶
type Manifest ¶
func ManifestFrom ¶
func (*Manifest) AugmentProgram ¶ added in v0.2.28
AugmentProgram receives entrypoint ownership from the project pipeline so Ruby and TypeScript can bootstrap model registration without creating model-to-model initialization cycles.
func (*Manifest) EnumColumnsForModule ¶ added in v0.2.2
func (m *Manifest) EnumColumnsForModule(module string) []*EnumColumn
func (*Manifest) EquivalentForIncrementalLowering ¶ added in v0.3.13
EquivalentForIncrementalLowering compares the immutable contribution made by two manifests. Association scopes are captured from typed IR after this manifest is created and are guarded separately by module invalidation.
func (*Manifest) ExtensionName ¶
func (*Manifest) ModelsForModule ¶
func (*Manifest) RequiresIncrementalRelowering ¶ added in v0.3.13
RequiresIncrementalRelowering reports whether a changed module can alter an association scope captured from its typed IR.
type Model ¶
type Model struct {
Name string
QueryType string
Table string
ModulePath string
Columns []Column
Associations []Association
UniqueConstraints []UniqueConstraint
}
func (Model) Association ¶
func (m Model) Association(name string) (Association, bool)
func (Model) ChangesType ¶
func (Model) PrimaryKey ¶
type Operator ¶
type Operator string
const ( Equal Operator = "=" NotEqual Operator = "!=" LessThan Operator = "<" LessThanOrEqual Operator = "<=" GreaterThan Operator = ">" GreaterThanOrEqual Operator = ">=" In Operator = "IN" RangeInclusive Operator = "RANGE_INCLUSIVE" RangeExclusive Operator = "RANGE_EXCLUSIVE" NotIn Operator = "NOT_IN" )
type Predicate ¶
type Predicate struct {
Column string
Operator Operator
Value ir.Expression
}
func Predicates ¶
type Schema ¶
func InspectSchema ¶ added in v0.2.1
type Table ¶
type Table struct {
Name string
Columns []Column
ForeignKeys []ForeignKey
UniqueConstraints []UniqueConstraint
}