Documentation
¶
Overview ¶
This package has SQL parser, its abstraction and SQL generator. Never touch database.
Index ¶
- Constants
- func GenerateIdempotentDDLs(mode GeneratorMode, sqlParser database.Parser, desiredSQL string, ...) ([]string, error)
- func StringConstant(s string) string
- type AddExclusion
- type AddForeignKey
- type AddIndex
- type AddPolicy
- type AddPrimaryKey
- type AggregatedSchema
- type CheckDefinition
- type Column
- type ColumnKeyOption
- type Comment
- type ConstraintOptions
- type CreateIndex
- type CreateTable
- type DDL
- func FilterPrivileges(ddls []DDL, config database.GeneratorConfig) []DDL
- func FilterTables(ddls []DDL, config database.GeneratorConfig) []DDL
- func FilterViews(ddls []DDL, config database.GeneratorConfig) []DDL
- func ParseDDLs(mode GeneratorMode, sqlParser database.Parser, sql string, ...) ([]DDL, error)
- func SortTablesByDependencies(ddls []DDL) []DDL
- type DefaultDefinition
- type Domain
- type DomainConstraint
- type Exclusion
- type ExclusionPair
- type Extension
- type ForeignKey
- type Generated
- type GeneratedType
- type Generator
- type GeneratorMode
- type GrantPrivilege
- type Identity
- type Index
- type IndexColumn
- type IndexOption
- type IndexPartition
- type Policy
- type RevokePrivilege
- type Schema
- type Sequence
- type SridDefinition
- type Table
- type TablePrivilege
- type Trigger
- type Type
- type Value
- type ValueType
- type View
Constants ¶
const ( AscScr = "asc" DescScr = "desc" )
IndexColumn.direction
const ( ValueTypeStr = ValueType(iota) ValueTypeInt ValueTypeFloat ValueTypeHexNum ValueTypeHex ValueTypeValArg ValueTypeBit ValueTypeBool )
const ( ColumnKeyNone = ColumnKeyOption(iota) ColumnKeyPrimary ColumnKeySpatialKey ColumnKeyUnique ColumnKeyUniqueKey ColumnKey )
const ( GeneratedTypeVirtual = GeneratedType(iota) GeneratedTypeStored )
const ( GeneratorModeMysql = GeneratorMode(iota) GeneratorModePostgres GeneratorModeSQLite3 GeneratorModeMssql )
Variables ¶
This section is empty.
Functions ¶
func GenerateIdempotentDDLs ¶
func GenerateIdempotentDDLs(mode GeneratorMode, sqlParser database.Parser, desiredSQL string, currentSQL string, config database.GeneratorConfig, defaultSchema string) ([]string, error)
Parse argument DDLs and call `generateDDLs()`
func StringConstant ¶
Escape a string and add quotes to form a legal SQL string constant.
Types ¶
type AddExclusion ¶
type AddExclusion struct {
// contains filtered or unexported fields
}
func (*AddExclusion) Statement ¶
func (a *AddExclusion) Statement() string
type AddForeignKey ¶
type AddForeignKey struct {
// contains filtered or unexported fields
}
func (*AddForeignKey) Statement ¶
func (a *AddForeignKey) Statement() string
type AddPrimaryKey ¶
type AddPrimaryKey struct {
// contains filtered or unexported fields
}
func (*AddPrimaryKey) Statement ¶
func (a *AddPrimaryKey) Statement() string
type AggregatedSchema ¶
type CheckDefinition ¶
type CheckDefinition struct {
// contains filtered or unexported fields
}
type ColumnKeyOption ¶
type ColumnKeyOption int
type ConstraintOptions ¶
type ConstraintOptions struct {
// contains filtered or unexported fields
}
type CreateIndex ¶
type CreateIndex struct {
// contains filtered or unexported fields
}
func (*CreateIndex) Statement ¶
func (c *CreateIndex) Statement() string
type CreateTable ¶
type CreateTable struct {
// contains filtered or unexported fields
}
func (*CreateTable) Statement ¶
func (c *CreateTable) Statement() string
type DDL ¶
type DDL interface {
Statement() string
}
func FilterPrivileges ¶
func FilterPrivileges(ddls []DDL, config database.GeneratorConfig) []DDL
func FilterTables ¶
func FilterTables(ddls []DDL, config database.GeneratorConfig) []DDL
func FilterViews ¶
func FilterViews(ddls []DDL, config database.GeneratorConfig) []DDL
func ParseDDLs ¶
func ParseDDLs(mode GeneratorMode, sqlParser database.Parser, sql string, defaultSchema string) ([]DDL, error)
Parse `ddls`, which is expected to `;`-concatenated DDLs and not to include destructive DDL.
func SortTablesByDependencies ¶ added in v3.1.0
SortTablesByDependencies sorts CREATE TABLE DDLs by foreign key dependencies to ensure tables are created in the correct order (referenced tables before referencing tables) Also ensures CREATE TYPE statements are placed before CREATE TABLE statements that use them
type DefaultDefinition ¶
type DefaultDefinition struct {
// contains filtered or unexported fields
}
type DomainConstraint ¶ added in v3.6.0
type DomainConstraint struct {
// contains filtered or unexported fields
}
type ExclusionPair ¶
type ExclusionPair struct {
// contains filtered or unexported fields
}
type ForeignKey ¶
type ForeignKey struct {
// contains filtered or unexported fields
}
type GeneratedType ¶
type GeneratedType int
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
This struct holds simulated schema states during GenerateIdempotentDDLs().
type GeneratorMode ¶
type GeneratorMode int
type GrantPrivilege ¶
type GrantPrivilege struct {
// contains filtered or unexported fields
}
func (*GrantPrivilege) Statement ¶
func (g *GrantPrivilege) Statement() string
type IndexColumn ¶
type IndexColumn struct {
// contains filtered or unexported fields
}
func (IndexColumn) ColumnName ¶ added in v3.2.1
func (ic IndexColumn) ColumnName() string
ColumnName returns the column name if this is a simple column reference. For functional indexes or expressions, it returns the string representation.
type IndexOption ¶
type IndexOption struct {
// contains filtered or unexported fields
}
type IndexPartition ¶
type IndexPartition struct {
// contains filtered or unexported fields
}
type RevokePrivilege ¶
type RevokePrivilege struct {
// contains filtered or unexported fields
}
func (*RevokePrivilege) Statement ¶
func (r *RevokePrivilege) Statement() string
type SridDefinition ¶
type SridDefinition struct {
// contains filtered or unexported fields
}
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) PrimaryKey ¶
type TablePrivilege ¶
type TablePrivilege struct {
// contains filtered or unexported fields
}