fix get functions parameters without name (#60)

This commit is contained in:
Jakub Podhorský 2020-05-07 09:04:37 +02:00 committed by GitHub
parent 394b08b2fe
commit 7bbb56a328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -260,7 +260,7 @@ type DBFunction struct {
type DBFuncParam struct { type DBFuncParam struct {
ID int ID int
Name string Name sql.NullString
Type string Type string
} }
@ -291,6 +291,7 @@ ORDER BY
var funcs []DBFunction var funcs []DBFunction
fm := make(map[string]int) fm := make(map[string]int)
parameterIndex := 1
for rows.Next() { for rows.Next() {
var fn, fid string var fn, fid string
fp := DBFuncParam{} fp := DBFuncParam{}
@ -300,12 +301,18 @@ ORDER BY
return nil, err return nil, err
} }
if !fp.Name.Valid {
fp.Name.String = string(parameterIndex)
fp.Name.Valid = true
}
if i, ok := fm[fid]; ok { if i, ok := fm[fid]; ok {
funcs[i].Params = append(funcs[i].Params, fp) funcs[i].Params = append(funcs[i].Params, fp)
} else { } else {
funcs = append(funcs, DBFunction{Name: fn, Params: []DBFuncParam{fp}}) funcs = append(funcs, DBFunction{Name: fn, Params: []DBFuncParam{fp}})
fm[fid] = len(funcs) - 1 fm[fid] = len(funcs) - 1
} }
parameterIndex++
} }
return funcs, nil return funcs, nil