(sel *SqlSelect, m Columns)
| 105 | return sql2 |
| 106 | } |
| 107 | func rewriteIntoProjection(sel *SqlSelect, m Columns) { |
| 108 | if len(m) == 0 { |
| 109 | return |
| 110 | } |
| 111 | colsToAdd := make([]string, 0) |
| 112 | for _, c := range m { |
| 113 | // u.Infof("source=%-15s as=%-15s exprT:%T expr=%s star:%v", c.As, c.SourceField, c.Expr, c.Expr, c.Star) |
| 114 | switch n := c.Expr.(type) { |
| 115 | case *expr.IdentityNode: |
| 116 | colsToAdd = append(colsToAdd, c.SourceField) |
| 117 | case *expr.FuncNode: |
| 118 | |
| 119 | idents := expr.FindAllIdentities(n) |
| 120 | for _, in := range idents { |
| 121 | _, r, _ := in.LeftRight() |
| 122 | colsToAdd = append(colsToAdd, r) |
| 123 | } |
| 124 | |
| 125 | case nil: |
| 126 | if c.Star { |
| 127 | colsToAdd = append(colsToAdd, "*") |
| 128 | } else { |
| 129 | u.Warnf("unhandled column? %T %s", n, n) |
| 130 | } |
| 131 | |
| 132 | default: |
| 133 | u.Warnf("unhandled column? %T %s", n, n) |
| 134 | } |
| 135 | } |
| 136 | addIntoProjection(sel, colsToAdd) |
| 137 | } |
| 138 | func addIntoProjection(sel *SqlSelect, newCols []string) { |
| 139 | notExists := make(map[string]bool) |
| 140 | for _, colName := range newCols { |
no test coverage detected