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

Method getCols

internal/engine/sqlite/convert.go:575–607  ·  view source on GitHub ↗
(core *parser.Select_coreContext)

Source from the content-addressed store, hash-verified

573}
574
575func (c *cc) getCols(core *parser.Select_coreContext) []ast.Node {
576 var cols []ast.Node
577 for _, icol := range core.AllResult_column() {
578 col, ok := icol.(*parser.Result_columnContext)
579 if !ok {
580 continue
581 }
582 target := &ast.ResTarget{
583 Location: col.GetStart().GetStart(),
584 }
585 var val ast.Node
586 iexpr := col.Expr()
587 switch {
588 case col.STAR() != nil:
589 val = c.convertWildCardField(col)
590 case iexpr != nil:
591 val = c.convert(iexpr)
592 }
593
594 if val == nil {
595 continue
596 }
597
598 if col.Column_alias() != nil {
599 name := identifier(col.Column_alias().GetText())
600 target.Name = &name
601 }
602
603 target.Val = val
604 cols = append(cols, target)
605 }
606 return cols
607}
608
609func (c *cc) convertWildCardField(n *parser.Result_columnContext) *ast.ColumnRef {
610 items := []ast.Node{}

Callers 1

Calls 9

convertWildCardFieldMethod · 0.95
convertMethod · 0.95
GetStartMethod · 0.80
GetTextMethod · 0.80
identifierFunction · 0.70
AllResult_columnMethod · 0.65
ExprMethod · 0.65
STARMethod · 0.65
Column_aliasMethod · 0.65

Tested by

no test coverage detected