Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Definition ¶
type Definition struct {
Table string
Timing string // "BEFORE" or "AFTER"
Event string // "INSERT", "UPDATE", or "DELETE"
Sets map[string]Expr
Body string // raw full trigger body; required for DELETE (no NEW row to assign into)
Name string // optional; if empty, dbobjects will generate one
// PrimaryKey is the table's single primary key column, set only when
// Timing is AFTER and Sets is non-empty. NEW isn't assignable once an
// AFTER trigger fires (the row's already written), so the dialect
// renders Set() there as an explicit follow-up UPDATE targeting this
// column instead of NEW.col = expr -- see dialect.go's renderTrigger.
PrimaryKey string
}
Definition is the DB-agnostic description of a trigger, produced by Build() and consumed by whatever applies it (e.g. dbobjects.Register).
type Expr ¶
Expr represents a value assigned to a column inside the trigger body. Raw is written into the generated SQL verbatim, so callers should only build it via Now()/Raw() rather than embedding untrusted input.
type ExprKind ¶
type ExprKind int
ExprKind distinguishes what an Expr represents, so a dialect can render it in its own engine's spelling (Postgres/MySQL's NOW() vs SQL Server's SYSUTCDATETIME() vs Oracle's SYSDATE, for ExprNow) instead of Expr baking in one dialect's spelling itself.
type Trigger ¶
type Trigger interface {
Kind() string
Set(column string, value Expr) Trigger
SetColumns(columns map[string]Expr) Trigger
Body(sql string) Trigger
Name(n string) Trigger
Build() (*Definition, error)
}
func AfterDelete ¶ added in v0.2.0
func AfterInsert ¶ added in v0.2.0
func AfterUpdate ¶ added in v0.2.0
func BeforeDelete ¶ added in v0.2.0
func BeforeInsert ¶
func BeforeUpdate ¶
Click to show internal directories.
Click to hide internal directories.