dialect

package
v0.0.0-...-62db38d Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnSchema

type ColumnSchema interface {
	TableName() string
	ColumnName() string
	ColumnType() string
	DataType() string
	IsPrimaryKey() bool
	IsAutoIncrement() bool
	Index() (name string, unique bool, ok bool)
	Default() (string, bool)
	IsNullable() bool
	Extra() (string, bool)
	Comment() (string, bool)
}

type ColumnType

type ColumnType struct {
	Types           []string `yaml:"types"`
	GoTypes         []string `yaml:"goTypes"`
	GoNullableTypes []string `yaml:"goNullableTypes"`
	GoUnsignedTypes []string `yaml:"goUnsignedTypes"`
}

type Dialect

type Dialect interface {
	ColumnType(name string) string
	GoType(name string, nullable bool) string
	IsNullable(name string) bool
	ImportPackage(schema ColumnSchema) string
	Quote(s string) string
	QuoteString(s string) string

	CreateTableSQL(table Table) []string
	DropTableSQL(table Table) []string
	FindAllSQL(table Table) []string
	FindSQL(table Table) []string
	CreateSQL(table Table) []string
	DeleteSQL(table Table) []string
	UpdateSQL(table Table) []string
	AddColumnSQL(field Field) []string
	DropColumnSQL(field Field) []string
	ModifyColumnSQL(oldField, newField Field) []string
	CreateIndexSQL(index Index) []string
	DropIndexSQL(index Index) []string
}

func NewMySQL

func NewMySQL() Dialect

type Field

type Field struct {
	Table         string
	Name          string
	Type          string
	Comment       string
	AutoIncrement bool
	Default       string
	Extra         string
	Nullable      bool
	ForeignKey    *ForeignKey
}

type ForeignKey

type ForeignKey struct {
	Table  string
	Column string
}

type Index

type Index struct {
	Table   string
	Name    string
	Columns []string
	Unique  bool
}

type MySQL

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

func (*MySQL) AddColumnSQL

func (d *MySQL) AddColumnSQL(field Field) []string

func (*MySQL) ColumnType

func (d *MySQL) ColumnType(name string) string

func (*MySQL) CreateIndexSQL

func (d *MySQL) CreateIndexSQL(index Index) []string

func (*MySQL) CreateSQL

func (d *MySQL) CreateSQL(table Table) []string

func (*MySQL) CreateTableSQL

func (d *MySQL) CreateTableSQL(table Table) []string

func (*MySQL) DeleteSQL

func (d *MySQL) DeleteSQL(table Table) []string

func (*MySQL) DropColumnSQL

func (d *MySQL) DropColumnSQL(field Field) []string

func (*MySQL) DropIndexSQL

func (d *MySQL) DropIndexSQL(index Index) []string

func (*MySQL) DropTableSQL

func (d *MySQL) DropTableSQL(table Table) []string

func (*MySQL) FindAllSQL

func (d *MySQL) FindAllSQL(table Table) []string

func (*MySQL) FindSQL

func (d *MySQL) FindSQL(table Table) []string

func (*MySQL) GoType

func (d *MySQL) GoType(name string, nullable bool) string

func (*MySQL) ImportPackage

func (d *MySQL) ImportPackage(schema ColumnSchema) string

func (*MySQL) IsNullable

func (d *MySQL) IsNullable(name string) bool

func (*MySQL) ModifyColumnSQL

func (d *MySQL) ModifyColumnSQL(oldField, newField Field) []string

func (*MySQL) ModifyPrimaryKeySQL

func (d *MySQL) ModifyPrimaryKeySQL(oldPrimaryKeys, newPrimaryKeys []Field) []string

func (*MySQL) Quote

func (d *MySQL) Quote(s string) string

func (*MySQL) QuoteString

func (d *MySQL) QuoteString(s string) string

func (*MySQL) UpdateSQL

func (d *MySQL) UpdateSQL(table Table) []string

type PrimaryKeyModifier

type PrimaryKeyModifier interface {
	ModifyPrimaryKeySQL(oldPrimaryKeys, newPrimaryKeys []Field) []string
}

type Table

type Table struct {
	Name        string
	Fields      []Field
	PrimaryKeys []string
	ForeignKeys map[string]ForeignKey //map[columnName]reference
	Option      string
}

type Transactioner

type Transactioner interface {
	Exec(sql string, args ...interface{}) error
	Commit() error
	Rollback() error
}

Jump to

Keyboard shortcuts

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