dialect

package
v0.0.0-...-54a0d76 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2014 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIndexKey

func CreateIndexKey(this Dialect, key string, cols []ColumnMeta) (s string)

func CreatePrimaryKey

func CreatePrimaryKey(this Dialect, key string, cols []ColumnMeta) (s string)

func CreateTableSQL

func CreateTableSQL(this Dialect, schemaName, tableName string, ifNotExists bool, suffix string) string

func CreateUniqueKey

func CreateUniqueKey(this Dialect, key string, cols []ColumnMeta) (s string)

func DeleteSQL

func DeleteSQL(this Dialect, schemaName, tableName string) string

func DropTableSQL

func DropTableSQL(this Dialect, schemaName, tableName string, ifExists bool) string

func InsertAndReturnId

func InsertAndReturnId(this Dialect, exec exec_queryer, query string, args ...interface{}) (id int64, err error)

func InsertSQL

func InsertSQL(this Dialect, schemaName, tableName string, suffix string) string

func QuoteField

func QuoteField(f string) string

func Register

func Register(name string, newf newDialect)

func SelectSQL

func SelectSQL(this Dialect, schemaName, tableName string) string

func UpdateSQL

func UpdateSQL(this Dialect, schemaName, tableName string) string

Types

type ColumnMeta

type ColumnMeta interface {
	GetColumnName() string
	GetFieldName() string
	GetAutoIncr() bool
	GetNotNull() bool
	GetGoType() reflect.Type
	GetForceType() string
	GetSize() (int, int)
	GetDefault() (bool, string)
	GetComment() string
}

type Dialect

type Dialect interface {
	QuoteField(f string) string
	QuoteTable(schemaName, tableName string) string
	BindVar(i int) string
	BindAutoIncrVar() string
	InsertAndReturnId(exec exec_queryer, query string, args ...interface{}) (int64, error)

	PrimaryKeyStr() string
	UniqueKeyStr() string
	NormalKeyStr() string

	CreateSchema(schemaName string, ifNotExists bool) string
	CreateColumnStr(col ColumnMeta) string
	CreatePrimaryKey(key string, cols ...ColumnMeta) string
	CreateUniqueKey(key string, cols ...ColumnMeta) string
	CreateIndexKey(key string, cols ...ColumnMeta) string
	CreateTableSQL(schemaName, tableName string, ifNotExists bool, params map[string]string) string
	DropTableSQL(schemaName, tableName string, ifExists bool) string
	TruncateTableSQL(schemaName, tableName string) string
	InsertSQL(schemaName, tableName string, autoincr ColumnMeta) string
	UpdateSQL(schemaName, tableName string) string
	SelectSQL(schemaName, tableName string) string
	DeleteSQL(schemaName, tableName string) string
}

func Open

func Open(name string, params map[string]string) (dialect Dialect, err error)

type Execer

type Execer interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type Queryer

type Queryer interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

Jump to

Keyboard shortcuts

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