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(programs []*ast.Program, projectRoot string, options map[string][]byte, ...) (*declaration.Catalog, error)
- func EnumMemberStorageName(name string) string
- func IsGroupableColumn(column Column) bool
- func IsPortableTimeType(value types.Type) bool
- func TableName(model string) string
- type Adapter
- type Association
- type AssociationKind
- type Column
- type Config
- 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" )
Variables ¶
This section is empty.
Functions ¶
func AggregateOperations ¶
func AggregateOperations() []string
func AggregateResultType ¶
func Declarations ¶
func EnumMemberStorageName ¶ added in v0.2.2
func IsGroupableColumn ¶ added in v0.2.3
func IsPortableTimeType ¶ added in v0.2.3
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 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
}