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

Method getTables

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

Source from the content-addressed store, hash-verified

530}
531
532func (c *cc) getTables(core *parser.Select_coreContext) []ast.Node {
533 if core.Join_clause() != nil {
534 join := core.Join_clause().(*parser.Join_clauseContext)
535 tables := c.convertTablesOrSubquery(join.AllTable_or_subquery())
536 table := tables[0]
537 for i, t := range tables[1:] {
538 joinExpr := &ast.JoinExpr{
539 Larg: table,
540 Rarg: t,
541 }
542 jo := join.Join_operator(i)
543 if jo.NATURAL_() != nil {
544 joinExpr.IsNatural = true
545 }
546 switch {
547 case jo.CROSS_() != nil || jo.INNER_() != nil:
548 joinExpr.Jointype = ast.JoinTypeInner
549 case jo.LEFT_() != nil:
550 joinExpr.Jointype = ast.JoinTypeLeft
551 case jo.RIGHT_() != nil:
552 joinExpr.Jointype = ast.JoinTypeRight
553 case jo.FULL_() != nil:
554 joinExpr.Jointype = ast.JoinTypeFull
555 }
556 jc := join.Join_constraint(i)
557 switch {
558 case jc.ON_() != nil:
559 joinExpr.Quals = c.convert(jc.Expr())
560 case jc.USING_() != nil:
561 var using ast.List
562 for _, cn := range jc.AllColumn_name() {
563 using.Items = append(using.Items, NewIdentifier(cn.GetText()))
564 }
565 joinExpr.UsingClause = &using
566 }
567 table = joinExpr
568 }
569 return []ast.Node{table}
570 } else {
571 return c.convertTablesOrSubquery(core.AllTable_or_subquery())
572 }
573}
574
575func (c *cc) getCols(core *parser.Select_coreContext) []ast.Node {
576 var cols []ast.Node

Callers 1

Calls 15

convertMethod · 0.95
GetTextMethod · 0.80
NewIdentifierFunction · 0.70
Join_clauseMethod · 0.65
AllTable_or_subqueryMethod · 0.65
Join_operatorMethod · 0.65
NATURAL_Method · 0.65
CROSS_Method · 0.65
INNER_Method · 0.65
LEFT_Method · 0.65
RIGHT_Method · 0.65

Tested by

no test coverage detected