(expr chast.Expression)
| 172 | } |
| 173 | |
| 174 | func (c *cc) convertToResTarget(expr chast.Expression) *ast.ResTarget { |
| 175 | res := &ast.ResTarget{ |
| 176 | Location: expr.Pos().Offset, |
| 177 | } |
| 178 | |
| 179 | switch e := expr.(type) { |
| 180 | case *chast.Asterisk: |
| 181 | if e.Table != "" { |
| 182 | // table.* |
| 183 | res.Val = &ast.ColumnRef{ |
| 184 | Fields: &ast.List{ |
| 185 | Items: []ast.Node{ |
| 186 | NewIdentifier(e.Table), |
| 187 | &ast.A_Star{}, |
| 188 | }, |
| 189 | }, |
| 190 | } |
| 191 | } else { |
| 192 | // Just * |
| 193 | res.Val = &ast.ColumnRef{ |
| 194 | Fields: &ast.List{ |
| 195 | Items: []ast.Node{&ast.A_Star{}}, |
| 196 | }, |
| 197 | } |
| 198 | } |
| 199 | case *chast.AliasedExpr: |
| 200 | res.Name = &e.Alias |
| 201 | res.Val = c.convertExpr(e.Expr) |
| 202 | case *chast.Identifier: |
| 203 | if e.Alias != "" { |
| 204 | res.Name = &e.Alias |
| 205 | } |
| 206 | res.Val = c.convertIdentifier(e) |
| 207 | case *chast.FunctionCall: |
| 208 | if e.Alias != "" { |
| 209 | res.Name = &e.Alias |
| 210 | } |
| 211 | res.Val = c.convertFunctionCall(e) |
| 212 | default: |
| 213 | res.Val = c.convertExpr(expr) |
| 214 | } |
| 215 | |
| 216 | return res |
| 217 | } |
| 218 | |
| 219 | func (c *cc) convertTablesInSelectQuery(n *chast.TablesInSelectQuery) *ast.List { |
| 220 | if n == nil || len(n.Tables) == 0 { |
no test coverage detected