dialect

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateTable = "CREATE TABLE"
	AlterTable  = "ALTER TABLE"
	Add         = "ADD"
	Constraint  = "CONSTRAINT"
	PrimaryKey  = "PRIMARY KEY"
	NotNull     = "NOT NULL"
	Default     = "DEFAULT"
	IfNotExists = "IF NOT EXISTS"
)

SQL constructs that are the same accross supported dialects.

View Source
const DialectVariablePrefix = "Dialect."
View Source
const Postgresql = "postgresql"
View Source
const PostgresqlDefaultPort = 5432

Variables

View Source
var ErrInvalidVariableMethodType = errors.New("dbschema/dialect: invalid method type")
View Source
var ErrMethodDoesNotExist = errors.New("dbschema/dialect: method does not exist")
View Source
var ErrNotSupported = errors.New("dbschema/dialect: not supported")

Functions

func CallVariableMethodOnDialect

func CallVariableMethodOnDialect(d Dialect, name string) (value string, err error)

func DoubleColonCaster

func DoubleColonCaster(in, t string) string

func Expand

func Expand(expr string, v *vars.Variables, d Dialect) (string, error)

func NewDefaultEscapes

func NewDefaultEscapes() map[string]string

func Quote

func Quote(in, q string) string

Types

type Dialect

type Dialect interface {
	DBMS() string

	QuoteRef(in string) string
	QuoteConst(in string) string

	EscapeConst(in string) (string, bool)

	Cast(in, t string) string

	Placeholder(index int) string

	Integer() (string, error)
	Int8() (string, error)
	Int16() (string, error)
	Int32() (string, error)
	Int64() (string, error)

	Float32() (string, error)
	Float64() (string, error)

	Char32() (string, error)
	Char64() (string, error)
	Char128() (string, error)
	Char256() (string, error)

	VarChar32() (string, error)
	VarChar64() (string, error)
	VarChar128() (string, error)
	VarChar256() (string, error)
	VarChar512() (string, error)
	VarChar1024() (string, error)

	Text() (string, error)

	Timestamp() (string, error)
	TimestampTz() (string, error)
	Time() (string, error)
	TimeTz() (string, error)
	Date() (string, error)

	Bool() (string, error)

	UUID() (string, error)
}

Dialect is the contract that all database types must implement for dbschema to generate the correct SQL for a given DBMS dialect.

func NewDialect

func NewDialect(dbms string) (Dialect, error)

func NewDialectPostgresql

func NewDialectPostgresql() Dialect

type DialectStruct

type DialectStruct struct {
	DBMSValue string

	QuoteRefValue   string
	QuoteConstValue string

	Escapes map[string]string

	Caster func(value, t string) string

	PlaceholderValue func(num int) string

	IntegerValue string
	Int8Value    string
	Int16Value   string
	Int32Value   string
	Int64Value   string

	Float32Value string
	Float64Value string

	Char32Value  string
	Char64Value  string
	Char128Value string
	Char256Value string

	VarChar32Value   string
	VarChar64Value   string
	VarChar128Value  string
	VarChar256Value  string
	VarChar512Value  string
	VarChar1024Value string

	TextValue string

	TimestampValue   string
	TimestampTzValue string
	TimeValue        string
	TimeTzValue      string
	DateValue        string

	BoolValue string

	UUIDValue string
}

func (*DialectStruct) Bool

func (d *DialectStruct) Bool() (string, error)

func (*DialectStruct) Cast

func (d *DialectStruct) Cast(in, t string) string

func (*DialectStruct) Char128

func (d *DialectStruct) Char128() (string, error)

func (*DialectStruct) Char256

func (d *DialectStruct) Char256() (string, error)

func (*DialectStruct) Char32

func (d *DialectStruct) Char32() (string, error)

func (*DialectStruct) Char64

func (d *DialectStruct) Char64() (string, error)

func (*DialectStruct) DBMS

func (d *DialectStruct) DBMS() string

func (*DialectStruct) Date

func (d *DialectStruct) Date() (string, error)

func (*DialectStruct) EscapeConst

func (d *DialectStruct) EscapeConst(in string) (string, bool)

func (*DialectStruct) Float32

func (d *DialectStruct) Float32() (string, error)

func (*DialectStruct) Float64

func (d *DialectStruct) Float64() (string, error)

func (*DialectStruct) Int16

func (d *DialectStruct) Int16() (string, error)

func (*DialectStruct) Int32

func (d *DialectStruct) Int32() (string, error)

func (*DialectStruct) Int64

func (d *DialectStruct) Int64() (string, error)

func (*DialectStruct) Int8

func (d *DialectStruct) Int8() (string, error)

func (*DialectStruct) Integer

func (d *DialectStruct) Integer() (string, error)

func (*DialectStruct) Placeholder

func (d *DialectStruct) Placeholder(num int) string

func (*DialectStruct) QuoteConst

func (d *DialectStruct) QuoteConst(in string) string

func (*DialectStruct) QuoteRef

func (d *DialectStruct) QuoteRef(in string) string

func (*DialectStruct) Text

func (d *DialectStruct) Text() (string, error)

func (*DialectStruct) Time

func (d *DialectStruct) Time() (string, error)

func (*DialectStruct) TimeTz

func (d *DialectStruct) TimeTz() (string, error)

func (*DialectStruct) Timestamp

func (d *DialectStruct) Timestamp() (string, error)

func (*DialectStruct) TimestampTz

func (d *DialectStruct) TimestampTz() (string, error)

func (*DialectStruct) UUID

func (d *DialectStruct) UUID() (string, error)

UUID returns d.UUIDValue and ErrNotSupported if it is empty.

func (*DialectStruct) VarChar1024

func (d *DialectStruct) VarChar1024() (string, error)

func (*DialectStruct) VarChar128

func (d *DialectStruct) VarChar128() (string, error)

func (*DialectStruct) VarChar256

func (d *DialectStruct) VarChar256() (string, error)

func (*DialectStruct) VarChar32

func (d *DialectStruct) VarChar32() (string, error)

func (*DialectStruct) VarChar512

func (d *DialectStruct) VarChar512() (string, error)

func (*DialectStruct) VarChar64

func (d *DialectStruct) VarChar64() (string, error)

type ErrUnsupportedDBMS

type ErrUnsupportedDBMS string

func (ErrUnsupportedDBMS) Error

func (e ErrUnsupportedDBMS) Error() string

Jump to

Keyboard shortcuts

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