sq/libsq/ast/func.go
Neil O'Toole a1a89ee9dd
Support table and column names with spaces. (#156)
* 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
2023-03-22 00:17:34 -06:00

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)
}