Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
49 lines
981 B
Go
49 lines
981 B
Go
package validate
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/sqlc-dev/sqlc/internal/config"
|
|
"github.com/sqlc-dev/sqlc/internal/sql/ast"
|
|
"github.com/sqlc-dev/sqlc/internal/sql/astutils"
|
|
"github.com/sqlc-dev/sqlc/internal/sql/catalog"
|
|
"github.com/sqlc-dev/sqlc/internal/sql/sqlerr"
|
|
)
|
|
|
|
type funcCallVisitor struct {
|
|
catalog *catalog.Catalog
|
|
settings config.CombinedSettings
|
|
err error
|
|
}
|
|
|
|
func (v *funcCallVisitor) Visit(node ast.Node) astutils.Visitor {
|
|
if v.err != nil {
|
|
return nil
|
|
}
|
|
|
|
call, ok := node.(*ast.FuncCall)
|
|
if !ok {
|
|
return v
|
|
}
|
|
fn := call.Func
|
|
if fn == nil {
|
|
return v
|
|
}
|
|
|
|
fun, err := v.catalog.ResolveFuncCall(call)
|
|
if fun != nil {
|
|
return v
|
|
}
|
|
if errors.Is(err, sqlerr.NotFound) && !v.settings.Package.StrictFunctionChecks {
|
|
return v
|
|
}
|
|
v.err = err
|
|
return nil
|
|
}
|
|
|
|
func FuncCall(c *catalog.Catalog, cs config.CombinedSettings, n ast.Node) error {
|
|
visitor := funcCallVisitor{catalog: c, settings: cs}
|
|
astutils.Walk(&visitor, n)
|
|
return visitor.err
|
|
}
|