MCPcopy
hub / github.com/sqlc-dev/sqlc / getFunc

Method getFunc

internal/sql/catalog/schema.go:21–44  ·  view source on GitHub ↗
(rel *ast.FuncName, tns []*ast.TypeName)

Source from the content-addressed store, hash-verified

19}
20
21func (s *Schema) getFunc(rel *ast.FuncName, tns []*ast.TypeName) (*Function, int, error) {
22 for i := range s.Funcs {
23 if !strings.EqualFold(s.Funcs[i].Name, rel.Name) {
24 continue
25 }
26
27 args := s.Funcs[i].InArgs()
28 if len(args) != len(tns) {
29 continue
30 }
31 found := true
32 for j := range args {
33 if !sameType(s.Funcs[i].Args[j].Type, tns[j]) {
34 found = false
35 break
36 }
37 }
38 if !found {
39 continue
40 }
41 return s.Funcs[i], i, nil
42 }
43 return nil, -1, sqlerr.RelationNotFound(rel.Name)
44}
45
46func (s *Schema) getFuncByName(rel *ast.FuncName) (*Function, int, error) {
47 idx := -1

Callers 2

createFunctionMethod · 0.80
dropFunctionMethod · 0.80

Calls 3

RelationNotFoundFunction · 0.92
sameTypeFunction · 0.85
InArgsMethod · 0.80

Tested by

no test coverage detected