本文整理匯總了Golang中github.com/youtube/vitess/go/vt/sqlparser.SQLNode類的典型用法代碼示例。如果您正苦於以下問題:Golang SQLNode類的具體用法?Golang SQLNode怎麽用?Golang SQLNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SQLNode類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: dmlFormatter
// dmlFormatter strips out keyspace name from dmls.
func dmlFormatter(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) {
switch node := node.(type) {
case *sqlparser.TableName:
node.Name.Format(buf)
return
}
node.Format(buf)
}
示例2: FormatWithBind
func FormatWithBind(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) {
switch node := node.(type) {
case sqlparser.StrVal, sqlparser.NumVal:
buf.WriteArg(fmt.Sprintf("v%d", bindIndex))
bindIndex++
default:
node.Format(buf)
}
}
示例3: FormatImpossible
// FormatImpossible is a callback function used by TrackedBuffer
// to generate a modified version of the query where all selects
// have impossible where clauses. It overrides a few node types
// and passes the rest down to the default FormatNode.
func FormatImpossible(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) {
switch node := node.(type) {
case *sqlparser.Select:
buf.Myprintf("select %v from %v where 1 != 1", node.SelectExprs, node.From)
case *sqlparser.JoinTableExpr:
if node.Join == sqlparser.LeftJoinStr || node.Join == sqlparser.RightJoinStr {
// ON clause is requried
buf.Myprintf("%v %s %v on 1 != 1", node.LeftExpr, node.Join, node.RightExpr)
} else {
buf.Myprintf("%v %s %v", node.LeftExpr, node.Join, node.RightExpr)
}
default:
node.Format(buf)
}
}