sq/libsq/ast/func.go
Neil O'Toole 9746f4c1a2
orderby() (#159)
* wip: orderby impl

* Tests passing (note: ast.checkASTIntegrity is disabled)

* ExprNode now rendered via renderSelectorNode

* linting

* CHAGELOG for v0.27.0
2023-03-25 19:20:53 -06:00

55 lines
1.0 KiB
Go

package ast
var (
_ Node = (*FuncNode)(nil)
_ ResultColumn = (*FuncNode)(nil)
)
// FuncNode models a function. For example, "COUNT()".
type FuncNode struct {
baseNode
fnName string
alias string
}
// FuncName returns the function name.
func (fn *FuncNode) FuncName() string {
return fn.fnName
}
// String returns a log/debug-friendly representation.
func (fn *FuncNode) String() string {
str := nodeString(fn)
if fn.alias != "" {
str += ":" + fn.alias
}
return str
}
// Text implements ResultColumn.
func (fn *FuncNode) Text() string {
return fn.ctx.GetText()
}
// Alias implements ResultColumn.
func (fn *FuncNode) Alias() string {
return fn.alias
}
// SetChildren implements Node.
func (fn *FuncNode) SetChildren(children []Node) error {
fn.setChildren(children)
return nil
}
// IsColumn implements ResultColumn.
func (fn *FuncNode) IsColumn() bool {
return false
}
func (fn *FuncNode) AddChild(child Node) error {
// TODO: add check for valid FuncNode child types
fn.addChild(child)
return child.SetParent(fn)
}