Documentation
¶
Index ¶
- Constants
- Variables
- type Dialect
- type SQLTemplate
- func (st SQLTemplate) AddFunc(name string, fn interface{}) SQLTemplate
- func (st SQLTemplate) AddFuncs(funcs map[string]interface{}) SQLTemplate
- func (st SQLTemplate) Exec(text string, m map[string]interface{}) (string, []interface{}, error)
- func (st SQLTemplate) ExecNamed(text string, m map[string]interface{}) (string, []sql.NamedArg, error)
Constants ¶
View Source
const ( // LeftDelim is start delimiter for SQL template. LeftDelim = "/*%" // RightDelim is end delimiter for SQL template. RightDelim = "%*/" // Connector is delimiter that is used when `sqlt` makes original argument name. Connector = "__" )
Variables ¶
View Source
var ( // Postgres is PostgreSQL dialect resolver. Postgres = postgres{} // MySQL is MySQL dialect resolver. MySQL = mysql{} // Oracle is Oracle dialect resolver. Oracle = oracle{} // SQLServer is SQLServer dialect resolver. SQLServer = sqlserver{} )
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect interface {
// IsOrdinalPlaceholderSupportedreturns true if databse support ordinal placeholder.
// ex: $1, $2 (PostgreSQL)
IsOrdinalPlaceholderSupported() bool
// OrdinalPlaceholderPrefix returns prefix of placeholder.
// This is used when IsOrdinalPlaceholderSupported is true in Exec func.
OrdinalPlaceholderPrefix() string
// Placeholder character.
// This is used when IsOrdinalPlaceholderSupported is false.
Placeholder() string
// NamedPlaceholderPrefix returns prefix of placeholder.
// This is used in ExecNamed func.
NamedPlaceholderPrefix() string
// WildcardRunes are wildcard characters that are used with `LIKE`.
WildcardRunes() []rune
}
Dialect resolves dialect of each databse.
type SQLTemplate ¶
type SQLTemplate struct {
// TimeFunc used `time` and `now` function in template.
// This func should return current time.
// If this function is not set, used `time.Now()` as default function.
TimeFunc func() time.Time
// contains filtered or unexported fields
}
SQLTemplate is template struct.
func (SQLTemplate) AddFunc ¶ added in v1.2.0
func (st SQLTemplate) AddFunc(name string, fn interface{}) SQLTemplate
AddFunc add custom template func.
func (SQLTemplate) AddFuncs ¶ added in v1.2.0
func (st SQLTemplate) AddFuncs(funcs map[string]interface{}) SQLTemplate
AddFuncs add custom template functions.
Source Files
¶
- context.go
- dialect.go
- funcs.go
- sqlt.go
- timer.go
Click to show internal directories.
Click to hide internal directories.
