AddColumn returns a Rule that appends a column expression to the SELECT list of a SELECT statement. The expression may be any valid AST expression node such as *ast.Identifier, *ast.AliasedExpression, or *ast.FunctionCall. Parameters: - expr: The column expression to append to the SELECT list Retu
(expr ast.Expression)
| 38 | // |
| 39 | // Returns ErrUnsupportedStatement for non-SELECT statements. |
| 40 | func AddColumn(expr ast.Expression) Rule { |
| 41 | return RuleFunc(func(stmt ast.Statement) error { |
| 42 | sel, err := getSelect(stmt, "AddColumn") |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | sel.Columns = append(sel.Columns, expr) |
| 47 | return nil |
| 48 | }) |
| 49 | } |
| 50 | |
| 51 | // RemoveColumn returns a Rule that removes the first column in the SELECT list that |
| 52 | // matches name. Matching is case-insensitive and checks both identifier names and |