| 166 | } |
| 167 | |
| 168 | func (t *translator) formProjection(scope *selectScope, in []ast.SQLAsExpr, inType super.Type) []column { |
| 169 | var out []column |
| 170 | scores := make(map[string]int) |
| 171 | for _, as := range in { |
| 172 | if star, ok := as.Expr.(*ast.StarExpr); ok { |
| 173 | // expand * and table.* expressions |
| 174 | paths, err := scope.star(star, star.Table, nil) |
| 175 | if err != nil { |
| 176 | t.error(as, err) |
| 177 | } |
| 178 | for _, p := range paths { |
| 179 | typ := t.checker.this(star, p, inType) |
| 180 | out = append(out, column{name: dedup(scores, t.asName(as.Label, nil, p.Path)), semExpr: p, typ: typ, astExpr: as.Expr}) |
| 181 | } |
| 182 | continue |
| 183 | } |
| 184 | lateral := as.Label != nil && as.Label.Name != "" |
| 185 | out = append(out, column{name: dedup(scores, t.asName(as.Label, as.Expr, nil)), astExpr: as.Expr, lateral: lateral}) |
| 186 | } |
| 187 | return out |
| 188 | } |
| 189 | |
| 190 | func (t *translator) asName(label *ast.ID, expr ast.Expr, path []string) string { |
| 191 | var name string |