MCPcopy
hub / github.com/sqlc-dev/sqlc / convertCommonTableExpression

Method convertCommonTableExpression

internal/engine/dolphin/convert.go:604–629  ·  view source on GitHub ↗
(n *pcast.CommonTableExpression)

Source from the content-addressed store, hash-verified

602}
603
604func (c *cc) convertCommonTableExpression(n *pcast.CommonTableExpression) *ast.CommonTableExpr {
605 if n == nil {
606 return nil
607 }
608
609 name := n.Name.String()
610
611 columns := &ast.List{}
612 for _, col := range n.ColNameList {
613 columns.Items = append(columns.Items, NewIdentifier(col.String()))
614 }
615
616 // CTE Query is wrapped in SubqueryExpr by TiDB parser.
617 // We need to unwrap it to get the SelectStmt directly,
618 // otherwise it would be double-wrapped with parentheses.
619 var cteQuery ast.Node
620 if n.Query != nil {
621 cteQuery = c.convert(n.Query.Query)
622 }
623
624 return &ast.CommonTableExpr{
625 Ctename: &name,
626 Ctequery: cteQuery,
627 Ctecolnames: columns,
628 }
629}
630
631func (c *cc) convertWithClause(n *pcast.WithClause) *ast.WithClause {
632 if n == nil {

Callers 1

convertWithClauseMethod · 0.95

Calls 3

convertMethod · 0.95
NewIdentifierFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected