sql

package
v0.0.0-...-4f09882 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeDict = map[string]string{
	"float32":         "float",
	"float64":         "float",
	"int":             "int",
	"uint":            "int",
	"int64":           "bigint",
	"uint64":          "bigint",
	"string":          "varchar",
	"time.Time":       "timestamp",
	"bool":            "tinyint",
	"[]byte":          "blob",
	"[]uint8":         "blob",
	"sql.NullFloat32": "float",
	"sql.NullFloat64": "float",
	"sql.NullInt64":   "bigint",
	"sql.NullString":  "varchar",
	"sql.NullBool":    "tinyint",
}
View Source
var Types = map[string]int{
	"int":       11,
	"bigint":    20,
	"varchar":   255,
	"text":      -1,
	"date":      -1,
	"time":      -1,
	"timestamp": -1,
}

Functions

func CallHook

func CallHook(st interface{}, method string, arg string) string

func DeleteQuery

func DeleteQuery(tableName, index string) string

func DropTableQuery

func DropTableQuery(name string, ifExists bool) string

func InsertQuery

func InsertQuery(st interface{}, tableName string, columnNames []string) string

func MatchType

func MatchType(typeName string) (string, error)

func NewFieldQueries

func NewFieldQueries(fields []*Options) string

func NewFieldQuery

func NewFieldQuery(field *Options) string

func NewPrimaryKeyQuery

func NewPrimaryKeyQuery(st interface{}, fields []*Options) string

func NewTableConfigQuery

func NewTableConfigQuery(fields []*Options) string

func NewTableQuery

func NewTableQuery(st interface{}, name string, fields []*Options, ifNotExists bool) string

func SelectQuery

func SelectQuery(tableName string, columnNames []string) string

func ShowTablesLikeQuery

func ShowTablesLikeQuery(name string) string

func UpdateAllQuery

func UpdateAllQuery(tableName string, columnNames []string) string

func UpdateQuery

func UpdateQuery(tableName, index string, columnNames []string) string

Types

type Options

type Options struct {
	Name               string
	Type               string
	Length             int
	DefaultValue       string
	AutoIncrement      int
	IsAutoIncrementing bool
	IsPrimaryKey       bool
	IsUnique           bool
	IsUnsigned         bool
	IsRequired         bool
	Ignore             bool
	Conflict           string
	TableName          string
}

func NewOptions

func NewOptions(input string) (*Options, error)

func (*Options) ReadAttr

func (options *Options) ReadAttr(input string, names ...string) (string, bool)

func (*Options) ReadAutoIncrement

func (options *Options) ReadAutoIncrement(input string) bool

func (*Options) ReadDefaultValue

func (options *Options) ReadDefaultValue(input string) bool

func (*Options) ReadName

func (options *Options) ReadName(input string) bool

func (*Options) ReadTableName

func (options *Options) ReadTableName(input string) bool

func (*Options) ReadType

func (options *Options) ReadType(input string) bool

func (*Options) ReadTypeAttr

func (options *Options) ReadTypeAttr(input string) bool

Jump to

Keyboard shortcuts

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