Documentation ¶
Index ¶
- Constants
- func AnalyzeTPLFromCache(template SQLTemplate, tpl string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{})
- func DefaultAnalyze(symbols Symbols, tpl string, input map[string]interface{}, ...) (string, []string, []interface{})
- func GetPropName(fullKey string) (propName string)
- func IsNil(input interface{}) bool
- func Register(tpl SQLTemplate)
- type DBParam
- type FixedContext
- func (ctx *FixedContext) AnalyzeTPL(tpl string, input map[string]interface{}, ph Placeholder) (sql string, names []string, values []interface{})
- func (ctx *FixedContext) GetSQLContext(tpl string, input map[string]interface{}) (query string, args []interface{})
- func (ctx *FixedContext) HandleAndSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
- func (ctx *FixedContext) HandleOrSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
- func (ctx FixedContext) Name() string
- func (ctx *FixedContext) Placeholder() Placeholder
- type Placeholder
- type ReplaceItem
- type SQLTemplate
- type SeqContext
- func (ctx *SeqContext) AnalyzeTPL(tpl string, input map[string]interface{}, ph Placeholder) (sql string, names []string, values []interface{})
- func (ctx *SeqContext) GetSQLContext(tpl string, input map[string]interface{}) (sql string, args []interface{})
- func (ctx *SeqContext) HandleAndSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
- func (ctx *SeqContext) HandleOrSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
- func (ctx SeqContext) Name() string
- func (ctx *SeqContext) Placeholder() Placeholder
- type SymbolCallback
- type Symbols
Constants ¶
View Source
const ( ParamPattern = `[@]\{\w+[\.]?\w+\}` AndPattern = `[&]\{\w+[\.]?\w+\}` OrPattern = `[\|]\{\w+[\.]?\w+\}` ReplacePattern = `\$\{\w+[\.]?\w+\}` )
Variables ¶
This section is empty.
Functions ¶
func AnalyzeTPLFromCache ¶
func AnalyzeTPLFromCache(template SQLTemplate, tpl string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{})
AnalyzeTPLFromCache 从缓存中获取已解析的SQL语句 @表达式,替换为参数化字符如: :1,:2,:3 $表达式,检查值,值为空时返加"",否则直接替换字符 &条件表达式,检查值,值为空时返加"",否则返回: and name=value |条件表达式,检查值,值为空时返回"", 否则返回: or name=value
func DefaultAnalyze ¶
func GetPropName ¶
func Register ¶
func Register(tpl SQLTemplate)
Types ¶
type FixedContext ¶
type FixedContext struct {
// contains filtered or unexported fields
}
FixedContext 模板
func (*FixedContext) AnalyzeTPL ¶
func (ctx *FixedContext) AnalyzeTPL(tpl string, input map[string]interface{}, ph Placeholder) (sql string, names []string, values []interface{})
func (*FixedContext) GetSQLContext ¶
func (ctx *FixedContext) GetSQLContext(tpl string, input map[string]interface{}) (query string, args []interface{})
GetSQLContext 获取查询串
func (*FixedContext) HandleAndSymbols ¶ added in v0.1.22
func (ctx *FixedContext) HandleAndSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
func (*FixedContext) HandleOrSymbols ¶ added in v0.1.22
func (ctx *FixedContext) HandleOrSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
func (FixedContext) Name ¶
func (ctx FixedContext) Name() string
func (*FixedContext) Placeholder ¶
func (ctx *FixedContext) Placeholder() Placeholder
type Placeholder ¶
type Placeholder interface { Get() string Clone() Placeholder }
type ReplaceItem ¶
type ReplaceItem struct { Names []string Values []interface{} NameCache map[string]string Placeholder Placeholder }
type SQLTemplate ¶
type SQLTemplate interface { Name() string Placeholder() Placeholder GetSQLContext(tpl string, input map[string]interface{}) (query string, args []interface{}) AnalyzeTPL(tpl string, input map[string]interface{}, ph Placeholder) (sql string, names []string, values []interface{}) HandleAndSymbols(tpl string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool) HandleOrSymbols(tpl string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool) }
Template 模板上下文
func NewFixed ¶
func NewFixed(name, prefix string) SQLTemplate
func NewSeq ¶
func NewSeq(name, prefix string) SQLTemplate
type SeqContext ¶
type SeqContext struct {
// contains filtered or unexported fields
}
SeqContext 参数化时使用@+参数名作为占位符的SQL数据库如:oracle,sql server
func (*SeqContext) AnalyzeTPL ¶
func (ctx *SeqContext) AnalyzeTPL(tpl string, input map[string]interface{}, ph Placeholder) (sql string, names []string, values []interface{})
func (*SeqContext) GetSQLContext ¶
func (ctx *SeqContext) GetSQLContext(tpl string, input map[string]interface{}) (sql string, args []interface{})
GetSQLContext 获取查询串
func (*SeqContext) HandleAndSymbols ¶ added in v0.1.22
func (ctx *SeqContext) HandleAndSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
func (*SeqContext) HandleOrSymbols ¶ added in v0.1.22
func (ctx *SeqContext) HandleOrSymbols(template string, input map[string]interface{}, ph Placeholder) (sql string, values []interface{}, exists bool)
func (SeqContext) Name ¶
func (ctx SeqContext) Name() string
func (*SeqContext) Placeholder ¶
func (ctx *SeqContext) Placeholder() Placeholder
type SymbolCallback ¶
type SymbolCallback func(DBParam, string, *ReplaceItem) string
type Symbols ¶
type Symbols map[string]SymbolCallback
Click to show internal directories.
Click to hide internal directories.