diff --git a/internal/jet/func_expression.go b/internal/jet/func_expression.go index d4eaa57..606e7e1 100644 --- a/internal/jet/func_expression.go +++ b/internal/jet/func_expression.go @@ -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) +} diff --git a/internal/jet/func_expression_test.go b/internal/jet/func_expression_test.go index c5a1e40..264be95 100644 --- a/internal/jet/func_expression_test.go +++ b/internal/jet/func_expression_test.go @@ -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)) +} diff --git a/mysql/expressions.go b/mysql/expressions.go index 2292108..5c5810d 100644 --- a/mysql/expressions.go +++ b/mysql/expressions.go @@ -74,5 +74,8 @@ var TimestampExp = jet.TimestampExp // For example: Raw("current_database()") var Raw = jet.Raw +// Func can be used to call an custom or as of yet unsupported function in the database. +var Func = jet.Func + // NewEnumValue creates new named enum value var NewEnumValue = jet.NewEnumValue diff --git a/postgres/expressions.go b/postgres/expressions.go index 61c0449..57a3335 100644 --- a/postgres/expressions.go +++ b/postgres/expressions.go @@ -85,5 +85,8 @@ var TimestampzExp = jet.TimestampzExp // For example: Raw("current_database()") var Raw = jet.Raw +// Func can be used to call an custom or as of yet unsupported function in the database. +var Func = jet.Func + // NewEnumValue creates new named enum value var NewEnumValue = jet.NewEnumValue