diff --git a/README.md b/README.md index 364f6804..3fbf7d3a 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ func main() { } ``` -Checkout the [SQL documentation](https://chaisql.com/docs/essentials/sql-introduction/), the [Go doc](https://pkg.go.dev/github.com/chaisql/chai) and the [usage example](#usage) in the README to get started quickly. +Checkout the [Go doc](https://pkg.go.dev/github.com/chaisql/chai) and the [usage example](#usage) in the README to get started quickly. ### In-memory database @@ -177,4 +177,4 @@ A big thanks to our [contributors](https://github.com/chaisql/chai/graphs/contri Made with [contrib.rocks](https://contrib.rocks). -For any questions or discussions, join our [Gophers Slack channel](https://gophers.slack.com/messages/CKPCYQFE0) or open an [issue](https://github.com/chaisql/chai/issues/new). +For any questions or discussions, open an [issue](https://github.com/chaisql/chai/issues/new). diff --git a/cmd/chai/doc/doc_test.go b/cmd/chai/doc/doc_test.go index 61f53756..b22ad52e 100644 --- a/cmd/chai/doc/doc_test.go +++ b/cmd/chai/doc/doc_test.go @@ -3,6 +3,7 @@ package doc_test import ( "fmt" "regexp" + "strings" "testing" "github.com/chaisql/chai/cmd/chai/doc" @@ -17,13 +18,24 @@ func TestFunctions(t *testing.T) { for pkgname, pkg := range packages { for fname, def := range pkg { if pkgname == "" { - t.Run(fmt.Sprintf("%s is documented and has all its arguments mentioned", fname), func(t *testing.T) { - str, err := doc.DocString(fname) - assert.NoError(t, err) - for i := 0; i < def.Arity(); i++ { - require.Contains(t, trimDocPromt(str), fmt.Sprintf("arg%d", i+1)) + var isAlias = false + for pkgname2, pkg2 := range packages { + if pkgname2 != "" { + _, ok := pkg2[strings.ToLower(fname)] + if ok { + isAlias = true + } } - }) + } + if !isAlias { + t.Run(fmt.Sprintf("%s is documented and has all its arguments mentioned", fname), func(t *testing.T) { + str, err := doc.DocString(fname) + assert.NoError(t, err) + for i := 0; i < def.Arity(); i++ { + require.Contains(t, trimDocPromt(str), fmt.Sprintf("arg%d", i+1)) + } + }) + } } else { t.Run(fmt.Sprintf("%s.%s is documented and has all its arguments mentioned", pkgname, fname), func(t *testing.T) { str, err := doc.DocString(fmt.Sprintf("%s.%s", pkgname, fname)) diff --git a/internal/expr/functions/builtins.go b/internal/expr/functions/builtins.go index 2c08e4e8..b7ef833a 100644 --- a/internal/expr/functions/builtins.go +++ b/internal/expr/functions/builtins.go @@ -81,6 +81,25 @@ var builtinFunctions = Definitions{ return &Now{}, nil }, }, + + // strings alias + "lower": stringsFunctions["lower"], + "upper": stringsFunctions["upper"], + "trim": stringsFunctions["trim"], + "ltrim": stringsFunctions["ltrim"], + "rtrim": stringsFunctions["rtrim"], + + // math alias + "floor": mathFunctions["floor"], + "abs": mathFunctions["abs"], + "acos": mathFunctions["acos"], + "acosh": mathFunctions["acosh"], + "asin": mathFunctions["asin"], + "asinh": mathFunctions["asinh"], + "atan": mathFunctions["atan"], + "atan2": mathFunctions["atan2"], + "random": mathFunctions["random"], + "sqrt": mathFunctions["sqrt"], } // BuiltinDefinitions returns a map of builtin functions. diff --git a/internal/expr/functions/math.go b/internal/expr/functions/math.go index 4315d932..8606a763 100644 --- a/internal/expr/functions/math.go +++ b/internal/expr/functions/math.go @@ -184,7 +184,7 @@ var sqrt = &ScalarDefinition{ if args[0].Type() != types.DoubleValue && args[0].Type() != types.IntegerValue { return types.NewNullValue(), nil } - v, err := document.CastAs(args[0], types.DoubleValue) + v, err := object.CastAs(args[0], types.DoubleValue) if err != nil { return nil, err }