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

Method Scan

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

Source from the content-addressed store, hash-verified

191}
192
193func (v QueryValue) Scan() string {
194 var out []string
195 if v.Struct == nil {
196 if strings.HasPrefix(v.Typ, "[]") && v.Typ != "[]byte" && !v.SQLDriver.IsPGX() {
197 out = append(out, "pq.Array(&"+v.Name+")")
198 } else {
199 out = append(out, "&"+v.Name)
200 }
201 } else {
202 for _, f := range v.Struct.Fields {
203
204 // append any embedded fields
205 if len(f.EmbedFields) > 0 {
206 for _, embed := range f.EmbedFields {
207 if strings.HasPrefix(embed.Type, "[]") && embed.Type != "[]byte" && !v.SQLDriver.IsPGX() {
208 out = append(out, "pq.Array(&"+v.Name+"."+f.Name+"."+embed.Name+")")
209 } else {
210 out = append(out, "&"+v.Name+"."+f.Name+"."+embed.Name)
211 }
212 }
213 continue
214 }
215
216 if strings.HasPrefix(f.Type, "[]") && f.Type != "[]byte" && !v.SQLDriver.IsPGX() {
217 out = append(out, "pq.Array(&"+v.Name+"."+f.Name+")")
218 } else {
219 out = append(out, "&"+v.Name+"."+f.Name)
220 }
221 }
222 }
223 if len(out) <= 3 {
224 return strings.Join(out, ",")
225 }
226 out = append(out, "")
227 return "\n" + strings.Join(out, ",\n")
228}
229
230// Deprecated: This method does not respect the Emit field set on the
231// QueryValue. It's used by the go-sql-driver-mysql/copyfromCopy.tmpl and should

Callers 14

scanRelationsFunction · 0.45
scanProcsFunction · 0.45
CreateDatabaseMethod · 0.45
SplitFunction · 0.45
StripCommentsFunction · 0.45
CleanedCommentsFunction · 0.45
getLinesFunction · 0.45
ExplainMethod · 0.45
ExplainMethod · 0.45
ParseCommentFlagsFunction · 0.45
RemoveRollbackStatementsFunction · 0.45
RemovePsqlMetaCommandsFunction · 0.45

Calls 2

IsPGXMethod · 0.80
JoinMethod · 0.45

Tested by

no test coverage detected