Add support for custom functions.

This allows expressions like jet.Func("FOO", String("test")) to be
emitted as FOO($1).
This commit is contained in:
tolfino 2020-09-29 15:29:35 -07:00
parent 29119d71d9
commit bc104d7dbb
4 changed files with 15 additions and 0 deletions

View file

@ -801,3 +801,8 @@ func newTimestampzFunc(name string, expressions ...Expression) *timestampzFunc {
return timestampzFunc
}
// Func can be used to call an custom or as of yet unsupported function in the database.
func Func(name string, expressions ...Expression) Expression {
return newFunc(name, expressions, nil)
}

View file

@ -176,3 +176,7 @@ func TestTO_ASCII(t *testing.T) {
assertClauseSerialize(t, TO_ASCII(String("Karel")), `TO_ASCII($1)`, "Karel")
assertClauseSerialize(t, TO_ASCII(String("Karel")), `TO_ASCII($1)`, "Karel")
}
func TestFunc(t *testing.T) {
assertClauseSerialize(t, Func("FOO", String("test"), NULL, MAX(Int(1))), "FOO($1, NULL, MAX($2))", "test", int64(1))
}