dialect

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//MySQL MySQL驱动
	MySQL = &Driver{
		Name:         "mysql",
		SupportNamed: true,
		NamedPrefix:  ":",
		DateFormat:   "'2006-01-02 15:04:05'",
		SQLNameFunc:  MakeNameFunc("`", "`"),
		NameFunc:     utils.LowerCase,
		PlaceHolder:  "?",
	}

	//SQLServer SQLServer驱动
	SQLServer = &Driver{
		Name:         "mssql",
		SupportNamed: true,
		NamedPrefix:  "@",
		PlaceHolder:  "?",
		DateFormat:   "'2006-01-02 15:04:05'",
		SQLNameFunc:  MakeNameFunc("[", "]"),
		NameFunc:     utils.LowerCase,
	}
)

Functions

func MakeNameFunc

func MakeNameFunc(prefix, suffix string) func(any) string

func QuotedName

func QuotedName(name any, prefix, suffix string) string

Types

type Driver

type Driver struct {
	//驱动名称(mysql/mssql)等
	Name string
	//是否使用命名参数
	SupportNamed bool
	//命名参数前缀
	NamedPrefix string
	//参数占位符
	PlaceHolder string
	//SQLNameFunc SQL名称转换函数
	SQLNameFunc func(any) string
	//NameFunc 字段名称转换函数
	NameFunc func(string) string
	//DateFormat 日期格式化
	DateFormat string
	//Keywords 关键字映射
	Keywords map[string]string
}

func (*Driver) Keyword

func (d *Driver) Keyword(name string) string

func (*Driver) KeywordWith

func (d *Driver) KeywordWith(prefix string, kw string, suffix string) string

func (*Driver) KeywordWithSpace

func (d *Driver) KeywordWithSpace(kw string) string

Jump to

Keyboard shortcuts

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