snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
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
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
This commit is contained in:
48
internal/sql/validate/func_call.go
Normal file
48
internal/sql/validate/func_call.go
Normal file
@@ -0,0 +1,48 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user