MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / convertJoin

Method convertJoin

internal/engine/dolphin/convert.go:1080–1120  ·  view source on GitHub ↗
(n *pcast.Join)

Source from the content-addressed store, hash-verified

1078}
1079
1080func (c *cc) convertJoin(n *pcast.Join) *ast.List {
1081 if n == nil {
1082 return &ast.List{}
1083 }
1084 if n.Right != nil && n.Left != nil {
1085 // MySQL doesn't have a FULL join type
1086 joinType := ast.JoinType(n.Tp)
1087 if joinType >= ast.JoinTypeFull {
1088 joinType++
1089 }
1090
1091 // Convert USING clause
1092 var usingClause *ast.List
1093 if len(n.Using) > 0 {
1094 items := make([]ast.Node, len(n.Using))
1095 for i, col := range n.Using {
1096 items[i] = &ast.String{Str: col.Name.O}
1097 }
1098 usingClause = &ast.List{Items: items}
1099 }
1100
1101 return &ast.List{
1102 Items: []ast.Node{&ast.JoinExpr{
1103 Jointype: joinType,
1104 IsNatural: n.NaturalJoin,
1105 Larg: c.convert(n.Left),
1106 Rarg: c.convert(n.Right),
1107 UsingClause: usingClause,
1108 Quals: c.convert(n.On),
1109 }},
1110 }
1111 }
1112 var tables []ast.Node
1113 if n.Right != nil {
1114 tables = append(tables, c.convert(n.Right))
1115 }
1116 if n.Left != nil {
1117 tables = append(tables, c.convert(n.Left))
1118 }
1119 return &ast.List{Items: tables}
1120}
1121
1122func (c *cc) convertKillStmt(n *pcast.KillStmt) ast.Node {
1123 return todo(n)

Callers 2

convertMethod · 0.95

Calls 2

convertMethod · 0.95
JoinTypeTypeAlias · 0.92

Tested by

no test coverage detected