schema

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnInfo

type ColumnInfo struct {
	// contains filtered or unexported fields
}

ColumnInfo is a sql col with options.

func (*ColumnInfo) GoType

func (c *ColumnInfo) GoType() GoType

GoType - field in go.

func (*ColumnInfo) Name

func (c *ColumnInfo) Name() string

Name - implements SQLColumn

func (*ColumnInfo) NameExpr

func (c *ColumnInfo) NameExpr() *ast.ColumnNameExpr

NameExpr - of the col.

func (*ColumnInfo) NotNull

func (c *ColumnInfo) NotNull() bool

NotNull - implements SQLColumn

func (*ColumnInfo) Type

func (c *ColumnInfo) Type() *types.FieldType

Type - SQL type.

type GoType

type GoType struct {
	Type    GoTypeName
	NotNull bool
}

GoType is the type that can be used in golang.

func EvalTypeToGoType

func EvalTypeToGoType(t *types.FieldType) GoType

EvalTypeToGoType - eval

func (GoType) String

func (g GoType) String() string

type GoTypeName

type GoTypeName = string

GoTypeName is the name of the type that can be used in golang.

const (
	// GoTypeInt int64
	GoTypeInt GoTypeName = "int64"
	// GoTypeFloat64 float64
	GoTypeFloat64 GoTypeName = "float64"
	// GoTypeString string
	GoTypeString GoTypeName = "string"
	// GoTypeTime time
	GoTypeTime GoTypeName = "time"
	// GoTypeBool bool
	GoTypeBool GoTypeName = "bool"
	// GoTypeJson json.RawMessage
	GoTypeJson GoTypeName = "RawMessage"
)

func EvalTypeToGoTypeName

func EvalTypeToGoTypeName(t *types.FieldType) GoTypeName

EvalTypeToGoTypeName - eval

type IndexInfo added in v0.4.1

type IndexInfo struct {
	// contains filtered or unexported fields
}

IndexInfo holds index info of SQL table.

func (*IndexInfo) IsPrimaryKey added in v0.4.1

func (s *IndexInfo) IsPrimaryKey() bool

func (*IndexInfo) KeyNames added in v0.4.1

func (s *IndexInfo) KeyNames() []string

Keys - implements SQLIndex

func (*IndexInfo) Name added in v0.4.1

func (s *IndexInfo) Name() string

Name - implements SQLIndex

type SQLColumn

type SQLColumn interface {
	Name() string
	NameExpr() *ast.ColumnNameExpr
	NotNull() bool
	Type() *types.FieldType
	GoType() GoType
}

SQLColumn is a sql defined column, immutable.

func NewColumnInfo

func NewColumnInfo(col *ast.ColumnDef) SQLColumn

NewColumnInfo -

type SQLIndex

type SQLIndex interface {
	Name() string
	IsPrimaryKey() bool
	KeyNames() []string
}

SQLIndex - index only, immutable.

func NewIndexInfo added in v0.4.1

func NewIndexInfo(cons *ast.Constraint) SQLIndex

NewIndexInfo -

type SQLTable

type SQLTable interface {
	Name() string
	Valid() error
	StarColumns() []SQLColumn
	Columns() []SQLColumn
	Indexes() []SQLIndex
	SQL() string
}

SQLTable represents a sql table schema, immutable.

func NewTableInfo

func NewTableInfo(s *ast.CreateTableStmt, hiddenFields []string) SQLTable

NewTableInfo -

type TableInfo

type TableInfo struct {
	// contains filtered or unexported fields
}

TableInfo - a table.

func (*TableInfo) Columns

func (t *TableInfo) Columns() []SQLColumn

Columns - implements SQLTable

func (*TableInfo) Indexes

func (t *TableInfo) Indexes() (rst []SQLIndex)

Indexes - implements SQLTable Should include constraints and keys with pk option.

func (*TableInfo) Name

func (t *TableInfo) Name() string

Name - implements SQLTable

func (*TableInfo) SQL

func (t *TableInfo) SQL() string

SQL - implements SQLTable

func (*TableInfo) StarColumns

func (t *TableInfo) StarColumns() (rst []SQLColumn)

StarColumns - implements SQLTable

func (*TableInfo) Valid

func (t *TableInfo) Valid() error

Valid return nil if valid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL