dialect

package
v0.0.0-...-26bbc2a Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTemplateFuncMap

func GetTemplateFuncMap() template.FuncMap

GetTemplateFuncMap returns functions to be used in template

func ParseColumnSignature

func ParseColumnSignature(field *descriptor.Field, type2SQLType func(*descriptor.Field) SQLType) (sqlType SQLType, at AdditionalType)

ParseColumnSignature return SQLType & AdditionalType

func RegisterDialect

func RegisterDialect(name string, dialect Dialect)

RegisterDialect register new dialect

func ToSnake

func ToSnake(in string) string

ToSnake converts column name to Snake case

Types

type AdditionalType

type AdditionalType struct {
	SetConstraint map[Constraint]bool
}

AdditionalType to know which constraint is added for a column

type Constraint

type Constraint string

Constraint for Column

const (
	ConstraintNotNull       Constraint = "NOT_NULL"
	ConstraintAutoIncrement Constraint = "AUTO_INCREMENT"
	ConstraintPrimaryKey    Constraint = "PRIMARY_KEY"
	ConstraintUnique        Constraint = "UNIQUE"
)

Supported Column Constraint

type Dialect

type Dialect interface {
	// GetUpSQL returns migration sql to create Table
	GetUpSQL(*descriptor.Message) (string, error)
	// GetDownSQL returns migration sql to delete Table
	GetDownSQL(*descriptor.Message) (string, error)
}

Dialect interface contains behaviors that differ across SQL database

func NewDialect

func NewDialect(name string) (Dialect, error)

NewDialect return registered Dialect

type SQLType

type SQLType struct {
	Name          string
	DefaultLength int
}

SQLType for Data type and Data size

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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