本文整理匯總了Golang中github.com/pingcap/tidb/ast.UnionStmt.Text方法的典型用法代碼示例。如果您正苦於以下問題:Golang UnionStmt.Text方法的具體用法?Golang UnionStmt.Text怎麽用?Golang UnionStmt.Text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/ast.UnionStmt
的用法示例。
在下文中一共展示了UnionStmt.Text方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: convertUnion
func convertUnion(converter *expressionConverter, u *ast.UnionStmt) (*stmts.UnionStmt, error) {
oldUnion := &stmts.UnionStmt{
Text: u.Text(),
}
oldUnion.Selects = make([]*stmts.SelectStmt, len(u.Selects))
oldUnion.Distincts = make([]bool, len(u.Selects)-1)
if u.Distinct {
for i := range oldUnion.Distincts {
oldUnion.Distincts[i] = true
}
}
for i, val := range u.Selects {
oldSelect, err := convertSelect(converter, val)
if err != nil {
return nil, errors.Trace(err)
}
oldUnion.Selects[i] = oldSelect
}
if u.OrderBy != nil {
oldOrderBy, err := convertOrderBy(converter, u.OrderBy)
if err != nil {
return nil, errors.Trace(err)
}
oldUnion.OrderBy = oldOrderBy
}
if u.Limit != nil {
if u.Limit.Offset > 0 {
oldUnion.Offset = &rsets.OffsetRset{Count: u.Limit.Offset}
}
if u.Limit.Count > 0 {
oldUnion.Limit = &rsets.LimitRset{Count: u.Limit.Count}
}
}
// Union order by can not converted to old because it is pushed to select statements.
return oldUnion, nil
}