Documentation ¶
Index ¶
- func OpenAstFile(path string) (*ast.File, string)
- func SwitchImportFilePath(f *ast.File, expr *ast.SelectorExpr) string
- func ToVarchar(size int64) string
- func TraversalAstDir(typeName, path, traversalFile string) string
- func TraversalFile(path, objName string) []*ast.Field
- type Analysis
- type AstConstraintDef
- type AstFieldDef
- type AstIndexDef
- type Constraint
- type ConstraintDef
- type DBTableDef
- type Field
- type FieldCursor
- type FieldType
- type IndexCursor
- type PGType
- type PrimaryDef
- type SqlSequenceDef
- type SqlTableFieldDef
- type SqlTableIndexDef
- type TableFieldDef
- type TableIndexDef
- type TableSql
- func (t *TableSql) AlterColumn() string
- func (t *TableSql) AlterIndex() string
- func (t *TableSql) AnalysisTable() *Analysis
- func (t *TableSql) CreateTable() string
- func (t *TableSql) Fields(seq func(string, string)) string
- func (t *TableSql) Index() string
- func (t *TableSql) Name() string
- func (t *TableSql) PrimaryKeyConstraint() string
- func (t *TableSql) PrimaryKeys() []string
- func (t *TableSql) Sequence(fieldName, seqName string) string
- type TableSqlBuild
- type TypeConvert
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenAstFile ¶
OpenAstFile /** Open ast.File and its fileName path target file full path
func SwitchImportFilePath ¶
func SwitchImportFilePath(f *ast.File, expr *ast.SelectorExpr) string
SwitchImportFilePath /** Base $GOPATH to switch import path with file path
func TraversalAstDir ¶
TraversalAstDir /** Traversal dir to search struct type which is not has traversal file, typeName struct type Name; path target search dir; traversalFile has traversal file; any error will panic
func TraversalFile ¶
TraversalFile /** Traversal file to collect all table define, path target search file; objName target struct name which can be empty; any error will panic
Types ¶
type AstConstraintDef ¶
type AstConstraintDef string
AstConstraintDef example: // @def primary ID
func (AstConstraintDef) Constraint ¶
func (astP AstConstraintDef) Constraint() *ConstraintDef
func (AstConstraintDef) String ¶
func (astP AstConstraintDef) String() string
type AstFieldDef ¶
type AstFieldDef string
AstFieldDef example `db:"name,size=10,default='0'"`
func (AstFieldDef) Field ¶
func (s AstFieldDef) Field() *TableFieldDef
type AstIndexDef ¶
type AstIndexDef string
AstIndexDef example // @def index i_name name (列别/索引名称/映射字段域名称)
func (AstIndexDef) Index ¶
func (s AstIndexDef) Index() *TableIndexDef
Index switch to TableIndexDef
type Constraint ¶
Constraint FieldConstraint 字段约束
func (Constraint) HasSizeConstraint ¶
func (f Constraint) HasSizeConstraint() string
func (Constraint) IncludeSequence ¶
func (f Constraint) IncludeSequence() bool
func (Constraint) String ¶
func (f Constraint) String() string
type ConstraintDef ¶
func PickConstraintDef ¶
func PickConstraintDef(doc *ast.CommentGroup) []*ConstraintDef
PickConstraintDef table constraint from doc
type DBTableDef ¶
type DBTableDef struct { // file name of picked Name string // all valid field define FieldDef []*TableFieldDef // all valid table index define IndexDef []*TableIndexDef // all valid doc constraint define ConstraintDef []*ConstraintDef }
DBTableDef database table define
func Def ¶
func Def(path string) *DBTableDef
Def /** parser table description file with return *DBTableDef
type Field ¶
type Field struct { Define string SqlSequenceDef }
type FieldCursor ¶
type FieldCursor uint8
const ( FieldCursorName FieldCursor = iota // 字段名称 FieldCursorType // 字段类型 FieldCursorConstraint // 字段约束 )
type FieldType ¶
type FieldType uint8
FieldType FieldType 字段类型
const ( PIndent FieldType Pint8 Puint8 Pint16 Puint16 Pint32 Puint32 Pint64 Puint64 Pint Pfloat32 Pfloat64 Pbyte Pstring )
type IndexCursor ¶
type IndexCursor uint8
const ( IndexCursorClass IndexCursor = iota // 索引类别 IndexCursorName // 索引字段 IndexCursorFields // 索引映射字段 )
type PrimaryDef ¶
type PrimaryDef []string
func (PrimaryDef) Primary ¶
func (p PrimaryDef) Primary() string
func (PrimaryDef) String ¶
func (p PrimaryDef) String() string
type SqlSequenceDef ¶
type SqlTableFieldDef ¶
type SqlTableFieldDef struct { TableName string *TableFieldDef }
func (*SqlTableFieldDef) HasSequence ¶
func (s *SqlTableFieldDef) HasSequence() bool
func (*SqlTableFieldDef) SequenceName ¶
func (f *SqlTableFieldDef) SequenceName() string
func (SqlTableFieldDef) String ¶
func (s SqlTableFieldDef) String() string
type SqlTableIndexDef ¶
type SqlTableIndexDef TableIndexDef
func (SqlTableIndexDef) Index ¶
func (in SqlTableIndexDef) Index() [3]string
func (SqlTableIndexDef) IsUnique ¶
func (in SqlTableIndexDef) IsUnique(class string) bool
func (SqlTableIndexDef) String ¶
func (in SqlTableIndexDef) String() string
type TableFieldDef ¶
type TableFieldDef struct { // 字段类型 DefType string // 字段名称 DefName string // 字段描述 DefDesc map[string]string }
TableFieldDef table field define
func PickFieldDef ¶
func PickFieldDef(fields ...*ast.Field) []*TableFieldDef
PickFieldDef table filed
type TableIndexDef ¶
type TableIndexDef struct { // 索引名称 DefName string // 索引类别 DefClass string // 索引关联字段名称 DefRelativeName []string }
TableIndexDef table index define
func PickIndexDef ¶
func PickIndexDef(doc *ast.CommentGroup) []*TableIndexDef
PickIndexDef table index
type TableSql ¶
type TableSql struct { DBName string Def *DBTableDef // contains filtered or unexported fields }
func NewTableSql ¶
func NewTableSql(dbName, tableName string, dbdef *DBTableDef) *TableSql
func (*TableSql) AlterColumn ¶
func (*TableSql) AlterIndex ¶
AlterIndex /** ALTER INDEX [ IF EXISTS ] name RENAME TO new_name ALTER INDEX [ IF EXISTS ] name SET TABLESPACE tablespace_name ALTER INDEX name ATTACH PARTITION index_name ALTER INDEX name DEPENDS ON EXTENSION extension_name ALTER INDEX [ IF EXISTS ] name SET ( storage_parameter [= value] [, ... ] ) ALTER INDEX [ IF EXISTS ] name RESET ( storage_parameter [, ... ] ) ALTER INDEX [ IF EXISTS ] name ALTER [ COLUMN ] column_number
SET STATISTICS integer
ALTER INDEX ALL IN TABLESPACE name [ OWNED BY role_name [, ... ] ]
SET TABLESPACE new_tablespace [ NOWAIT ]
Description
func (*TableSql) AnalysisTable ¶
func (*TableSql) CreateTable ¶
func (*TableSql) PrimaryKeyConstraint ¶
func (*TableSql) PrimaryKeys ¶
type TableSqlBuild ¶
type TableSqlBuild struct {
// contains filtered or unexported fields
}
func NewTableSqlBuild ¶
func NewTableSqlBuild(dbName, tableName, filePath string) *TableSqlBuild
func (*TableSqlBuild) Build ¶
func (t *TableSqlBuild) Build() *TableSql
type TypeConvert ¶
TypeConvert define to adapter different db
Source Files ¶
- abstract_table_build.go
- abstract_table_constraint_def.go
- abstract_table_def.go
- abstract_table_field_def.go
- abstract_table_field_priamry_def.go
- abstract_table_index_def.go
- postgres_type.go
- table_sql_build.go
- table_sql_build_sql.go
- table_sql_build_sql_analysis.go
- table_sql_field.go
- table_sql_field_constraint.go
- table_sql_field_type.go
- table_sql_index.go
- type_convert.go