mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 21:52:28 +03:00
a1a89ee9dd
* sakila: initial test data * sakila: more test data * sakila: yet more test data setup * whitespace cols: now working for sqlite * grammar cleanup * whitespace cols: now working inside count() func for sqlite * whitespace cols: tests mostly passing; begining refactoring * grammar: refactor handle * grammar: more refactoring * grammar: rename selElement to selector * wip * all tests passing * all tests passing * linting * driver: implement CurrentSchema for all driver.SQLDriver impls * driver: tests for AlterTableRename and AlterTableRenameColumn * undo reformat of SQL * undo reformat of SQL * undo reformat of SQL * undo reformat of SQL
55 lines
1004 B
Go
55 lines
1004 B
Go
package ast
|
|
|
|
var (
|
|
_ Node = (*Func)(nil)
|
|
_ ResultColumn = (*Func)(nil)
|
|
)
|
|
|
|
// Func models a function. For example, "COUNT()".
|
|
type Func struct {
|
|
baseNode
|
|
fnName string
|
|
alias string
|
|
}
|
|
|
|
// FuncName returns the function name.
|
|
func (fn *Func) FuncName() string {
|
|
return fn.fnName
|
|
}
|
|
|
|
// String returns a log/debug-friendly representation.
|
|
func (fn *Func) String() string {
|
|
str := nodeString(fn)
|
|
if fn.alias != "" {
|
|
str += ":" + fn.alias
|
|
}
|
|
return str
|
|
}
|
|
|
|
// Text implements ResultColumn.
|
|
func (fn *Func) Text() string {
|
|
return fn.ctx.GetText()
|
|
}
|
|
|
|
// Alias implements ResultColumn.
|
|
func (fn *Func) Alias() string {
|
|
return fn.alias
|
|
}
|
|
|
|
// SetChildren implements Node.
|
|
func (fn *Func) SetChildren(children []Node) error {
|
|
fn.setChildren(children)
|
|
return nil
|
|
}
|
|
|
|
// IsColumn implements ResultColumn.
|
|
func (fn *Func) IsColumn() bool {
|
|
return false
|
|
}
|
|
|
|
func (fn *Func) AddChild(child Node) error {
|
|
// TODO: add check for valid Func child types
|
|
fn.addChild(child)
|
|
return child.SetParent(fn)
|
|
}
|