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

Method Params

internal/codegen/golang/query.go:126–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124}
125
126func (v QueryValue) Params() string {
127 if v.isEmpty() {
128 return ""
129 }
130 var out []string
131 if v.Struct == nil {
132 if !v.Column.IsSqlcSlice && strings.HasPrefix(v.Typ, "[]") && v.Typ != "[]byte" && !v.SQLDriver.IsPGX() {
133 out = append(out, "pq.Array("+escape(v.Name)+")")
134 } else {
135 out = append(out, escape(v.Name))
136 }
137 } else {
138 for _, f := range v.Struct.Fields {
139 if !f.HasSqlcSlice() && strings.HasPrefix(f.Type, "[]") && f.Type != "[]byte" && !v.SQLDriver.IsPGX() {
140 out = append(out, "pq.Array("+escape(v.VariableForField(f))+")")
141 } else {
142 out = append(out, escape(v.VariableForField(f)))
143 }
144 }
145 }
146 if len(out) <= 3 {
147 return strings.Join(out, ",")
148 }
149 out = append(out, "")
150 return "\n" + strings.Join(out, ",\n")
151}
152
153func (v QueryValue) ColumnNames() []string {
154 if v.Struct == nil {

Callers

nothing calls this directly

Calls 6

isEmptyMethod · 0.95
VariableForFieldMethod · 0.95
escapeFunction · 0.85
IsPGXMethod · 0.80
HasSqlcSliceMethod · 0.80
JoinMethod · 0.45

Tested by

no test coverage detected