Documentation
¶
Index ¶
- type ColumnType
- type Database
- type DefaultValue
- type Ident
- type Index
- type IndexColumn
- type IndexColumnSortDirection
- type IndexKind
- type IndexOption
- type IndexType
- type Length
- type MaybeIdent
- type MaybeInteger
- type MaybeString
- type NullState
- type Reference
- type ReferenceMatch
- type ReferenceOption
- type Stmt
- type Stmts
- type Table
- func (t *Table) ID() string
- func (t *Table) LookupColumn(id string) (*TableColumn, bool)
- func (t *Table) LookupColumnBefore(id string) (*TableColumn, bool)
- func (t *Table) LookupColumnOrder(id string) (int, bool)
- func (t *Table) LookupIndex(id string) (*Index, bool)
- func (t *Table) Normalize() *Table
- type TableColumn
- type TableOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnType ¶
type ColumnType int
ColumnType describes the possible types that a column may take
const ( ColumnTypeInvalid ColumnType = iota ColumnTypeBigInt ColumnTypeBinary ColumnTypeBit ColumnTypeBlob ColumnTypeBool ColumnTypeBoolean ColumnTypeChar ColumnTypeDate ColumnTypeDateTime ColumnTypeDecimal ColumnTypeDouble ColumnTypeEnum ColumnTypeFloat ColumnTypeGeometry ColumnTypeGeometryCollection ColumnTypeInt ColumnTypeInteger ColumnTypeJSON ColumnTypeLineString ColumnTypeLongBlob ColumnTypeLongText ColumnTypeMediumBlob ColumnTypeMediumInt ColumnTypeMediumText ColumnTypeMultiLineString ColumnTypeMultiPoint ColumnTypeMultiPolygon ColumnTypeNumeric ColumnTypePoint ColumnTypePolygon ColumnTypeReal ColumnTypeSet ColumnTypeSmallInt ColumnTypeText ColumnTypeTime ColumnTypeTimestamp ColumnTypeTinyBlob ColumnTypeTinyInt ColumnTypeTinyText ColumnTypeVarBinary ColumnTypeVarChar ColumnTypeYear ColumnTypeMax )
List of possible ColumnType values
func (ColumnType) String ¶
func (c ColumnType) String() string
func (ColumnType) SynonymType ¶
func (c ColumnType) SynonymType() ColumnType
SynonymType returns synonym for a given type. If the type does not have a synonym then this method returns the receiver itself
type Database ¶
Database represents a database definition
func NewDatabase ¶
NewDatabase creates a new database mode with th given name
type DefaultValue ¶ added in v0.0.5
type Ident ¶ added in v0.0.5
type Ident string
Ident is a string for use as identifiers such as table and column names. It should be quoted to avoid confusion with reserved words.
type Index ¶
type Index struct {
Table string
Type IndexType
ConstraintName MaybeIdent
Kind IndexKind
Name MaybeIdent
Columns []*IndexColumn
Reference *Reference
Options []*IndexOption
}
Index describes an index on a table.
type IndexColumn ¶
type IndexColumn struct {
Name Ident
Length MaybeString
SortDirection IndexColumnSortDirection
}
IndexColumn is a column name/length specification used in indexes
func NewIndexColumn ¶
func NewIndexColumn(name Ident) *IndexColumn
func (*IndexColumn) ID ¶
func (col *IndexColumn) ID() string
type IndexColumnSortDirection ¶
type IndexColumnSortDirection int
const ( SortDirectionNone IndexColumnSortDirection = iota SortDirectionAscending SortDirectionDescending )
type IndexKind ¶
type IndexKind int
IndexKind describes the kind (purpose) of an index
type IndexOption ¶
IndexOption describes a possible index option, such as `WITH PARSER ngram`
func NewIndexOption ¶
func NewIndexOption(k, v string, q bool) *IndexOption
func (*IndexOption) ID ¶ added in v0.0.5
func (opt *IndexOption) ID() string
type Length ¶
type Length struct {
Decimals MaybeString
Length string
}
type MaybeIdent ¶ added in v0.0.5
MaybeIdent is an Ident that may not be set.
type MaybeInteger ¶ added in v0.0.8
MaybeInteger is an integer that may not be set.
type MaybeString ¶ added in v0.0.5
MaybeString is a string that may not be set.
type Reference ¶
type Reference struct {
TableName Ident
Columns []*IndexColumn
Match ReferenceMatch
OnDelete ReferenceOption
OnUpdate ReferenceOption
}
Reference describes a possible reference from one table to another
type ReferenceMatch ¶
type ReferenceMatch int
ReferenceMatch describes the matching method of a reference
const ( ReferenceMatchNone ReferenceMatch = iota ReferenceMatchFull ReferenceMatchPartial ReferenceMatchSimple )
List of possible ReferenceMatch values
func (ReferenceMatch) String ¶
func (i ReferenceMatch) String() string
type ReferenceOption ¶
type ReferenceOption int
ReferenceOption describes the actions that could be taken when a table/column referred by the reference has been deleted
const ( ReferenceOptionNone ReferenceOption = iota ReferenceOptionRestrict ReferenceOptionCascade ReferenceOptionSetNull ReferenceOptionNoAction )
List of possible ReferenceOption values
func (ReferenceOption) String ¶
func (i ReferenceOption) String() string
type Table ¶
type Table struct {
Name Ident
Temporary bool
IfNotExists bool
LikeTable MaybeIdent
Columns []*TableColumn
Indexes []*Index
Options []*TableOption
}
Table describes a table model
func (*Table) LookupColumn ¶
func (t *Table) LookupColumn(id string) (*TableColumn, bool)
func (*Table) LookupColumnBefore ¶
func (t *Table) LookupColumnBefore(id string) (*TableColumn, bool)
type TableColumn ¶
type TableColumn struct {
TableID string
Name Ident
Type ColumnType
Length *Length
NullState NullState
CharacterSet MaybeIdent
Collation MaybeIdent
Default DefaultValue
Comment MaybeString
AutoUpdate MaybeString
EnumValues []string
SetValues []string
AutoIncrement bool
Binary bool
Key bool
Primary bool
Unique bool
Unsigned bool
ZeroFill bool
SRID MaybeInteger
}
TableColumn describes a model object that describes a column definition of a table
func NewTableColumn ¶
func NewTableColumn(name string) *TableColumn
NewTableColumn creates a new TableColumn with the given name
func (*TableColumn) ID ¶ added in v0.0.5
func (t *TableColumn) ID() string
func (*TableColumn) NativeLength ¶
func (t *TableColumn) NativeLength() *Length
func (*TableColumn) Normalize ¶
func (t *TableColumn) Normalize() *TableColumn
type TableOption ¶
TableOption describes a possible table option, such as `ENGINE=InnoDB`
func NewTableOption ¶
func NewTableOption(k, v string, q bool) *TableOption
NewTableOption creates a new table option with the given name, value, and a flag indicating if quoting is necessary
func (*TableOption) ID ¶ added in v0.0.5
func (opt *TableOption) ID() string