Documentation
¶
Overview ¶
Package model defines normalized schema catalog types produced by the parser.
Index ¶
- func SortColumns(cols []*Column)
- func SortForeignKeys(keys []*ForeignKey)
- func SortIndexes(idxs []*Index)
- func SortUniqueKeys(keys []*UniqueKey)
- type Catalog
- type Column
- type Domain
- type DomainConstraint
- type Enum
- type ForeignKey
- type ForeignKeyRef
- type Index
- type PrimaryKey
- type Table
- type UniqueKey
- type Value
- type ValueKind
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortColumns ¶
func SortColumns(cols []*Column)
SortColumns provides deterministic ordering of columns by name.
func SortForeignKeys ¶
func SortForeignKeys(keys []*ForeignKey)
SortForeignKeys provides deterministic ordering of foreign key constraints by name then reference.
func SortIndexes ¶
func SortIndexes(idxs []*Index)
SortIndexes provides deterministic ordering of indexes by name.
func SortUniqueKeys ¶
func SortUniqueKeys(keys []*UniqueKey)
SortUniqueKeys provides deterministic ordering of unique constraints by name then columns.
Types ¶
type Catalog ¶
type Catalog struct {
Tables map[string]*Table
Views map[string]*View
Enums map[string]*Enum
Domains map[string]*Domain
}
Catalog represents the collection of tables and views discovered in DDL files.
type Column ¶
type Column struct {
Name string
Type string
NotNull bool
Default *Value
References *ForeignKeyRef
Span tokenizer.Span
}
Column describes a table column with optional inline constraints.
type Domain ¶ added in v0.5.0
type Domain struct {
Name string
BaseType string
Constraints []*DomainConstraint
Span tokenizer.Span
}
Domain represents a CREATE DOMAIN definition.
type DomainConstraint ¶ added in v0.5.0
type DomainConstraint struct {
Name string
Type string // "check", "not_null", "default"
Expr string
Span tokenizer.Span
}
DomainConstraint represents a constraint on a domain.
type ForeignKey ¶
type ForeignKey struct {
Name string
Columns []string
Ref ForeignKeyRef
Span tokenizer.Span
}
ForeignKey models a FOREIGN KEY constraint referencing another table.
type ForeignKeyRef ¶
ForeignKeyRef describes the referenced table and column set for a foreign key.
type PrimaryKey ¶
PrimaryKey captures a table's primary key declaration.
type Table ¶
type Table struct {
Name string
Doc string
Columns []*Column
PrimaryKey *PrimaryKey
UniqueKeys []*UniqueKey
ForeignKeys []*ForeignKey
Indexes []*Index
WithoutRowID bool
Strict bool
Span tokenizer.Span
}
Table models a SQLite table definition with associated constraints.
type ValueKind ¶
type ValueKind int
ValueKind identifies the literal kind stored in a Value.
const ( // ValueKindUnknown is used when the literal kind cannot be determined. ValueKindUnknown ValueKind = iota // ValueKindNumber represents numeric literals. ValueKindNumber // ValueKindString represents single-quoted string literals. ValueKindString // ValueKindBlob represents blob literals of the form X'...'. ValueKindBlob // ValueKindKeyword represents keywords used as literal defaults (e.g. CURRENT_TIMESTAMP). ValueKindKeyword )