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

Method Add

internal/sql/named/param_set.go:35–48  ·  view source on GitHub ↗

Add adds a parameter to this set and returns the numbered location used for it

(param Param)

Source from the content-addressed store, hash-verified

33
34// Add adds a parameter to this set and returns the numbered location used for it
35func (p *ParamSet) Add(param Param) int {
36 name := param.name
37 existing, ok := p.namedParams[name]
38
39 p.namedParams[name] = mergeParam(existing, param)
40 if ok && p.hasNamedSupport {
41 return p.namedLocs[name][0]
42 }
43
44 argn := p.nextArgNum()
45 p.positionToName[argn] = name
46 p.namedLocs[name] = append(p.namedLocs[name], argn)
47 return argn
48}
49
50// FetchMerge fetches an indexed parameter, and merges `mergeP` into it
51// Returns: the merged parameter and whether it was a named parameter

Callers 4

NamedParametersFunction · 0.95
TestParamSet_AddFunction · 0.45
waitForMySQLFunction · 0.45
waitForPostgresFunction · 0.45

Calls 2

nextArgNumMethod · 0.95
mergeParamFunction · 0.85

Tested by 1

TestParamSet_AddFunction · 0.36