dialect

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnSchema added in v0.4.0

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

type Dialect

type Dialect interface {
	ColumnSchema(tables ...string) ([]ColumnSchema, error)
	ColumnType(name string) string
	ImportPackage(schema ColumnSchema) string
	Quote(s string) string
	QuoteString(s string) string

	CreateTableSQL(table Table) []string
	AddColumnSQL(field Field) []string
	DropColumnSQL(field Field) []string
	ModifyColumnSQL(oldField, newfield Field) []string
	CreateIndexSQL(index Index) []string
	DropIndexSQL(index Index) []string

	Begin() (Transactioner, error)
}

func NewMySQL added in v0.4.0

func NewMySQL(db *sql.DB) Dialect

func NewSpanner added in v0.4.0

func NewSpanner(database string) Dialect

type Field added in v0.4.0

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

type Index added in v0.4.0

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

type MySQL

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

func (*MySQL) AddColumnSQL added in v0.4.0

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

func (*MySQL) Begin added in v0.4.0

func (d *MySQL) Begin() (Transactioner, error)

func (*MySQL) ColumnSchema added in v0.4.0

func (d *MySQL) ColumnSchema(tables ...string) ([]ColumnSchema, error)

func (*MySQL) ColumnType

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

func (*MySQL) CreateIndexSQL added in v0.4.0

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

func (*MySQL) CreateTableSQL added in v0.4.0

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

func (*MySQL) DropColumnSQL added in v0.4.0

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

func (*MySQL) DropIndexSQL added in v0.4.0

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

func (*MySQL) ImportPackage added in v0.4.0

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

func (*MySQL) ModifyColumnSQL added in v0.4.0

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

func (*MySQL) ModifyPrimaryKeySQL added in v0.4.0

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

func (*MySQL) Quote

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

func (*MySQL) QuoteString added in v0.2.0

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

type PrimaryKeyModifier added in v0.4.0

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

type Spanner added in v0.4.0

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

func (*Spanner) AddColumnSQL added in v0.4.0

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

func (*Spanner) Begin added in v0.4.0

func (d *Spanner) Begin() (Transactioner, error)

func (*Spanner) ColumnSchema added in v0.4.0

func (s *Spanner) ColumnSchema(tables ...string) ([]ColumnSchema, error)

func (*Spanner) ColumnType added in v0.4.0

func (s *Spanner) ColumnType(name string) string

func (*Spanner) CreateIndexSQL added in v0.4.0

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

func (*Spanner) CreateTableSQL added in v0.4.0

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

func (*Spanner) DropColumnSQL added in v0.4.0

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

func (*Spanner) DropIndexSQL added in v0.4.0

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

func (*Spanner) ImportPackage added in v0.4.0

func (s *Spanner) ImportPackage(schema ColumnSchema) string

func (*Spanner) ModifyColumnSQL added in v0.4.0

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

func (*Spanner) Quote added in v0.4.0

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

func (*Spanner) QuoteString added in v0.4.0

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

type Table added in v0.4.0

type Table struct {
	Name        string
	Fields      []Field
	PrimaryKeys []string
	Option      string
}

type Transactioner added in v0.4.0

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