MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / AddColumn

Function AddColumn

pkg/transform/columns.go:40–49  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

38//
39// Returns ErrUnsupportedStatement for non-SELECT statements.
40func 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

Callers 4

mainFunction · 0.92
TestAddColumnFunction · 0.85
AddSelectStarFunction · 0.85

Calls 2

RuleFuncFuncType · 0.85
getSelectFunction · 0.85

Tested by 2

TestAddColumnFunction · 0.68