本文整理汇总了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
}