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

Function countStarsInList

internal/x/expander/expander.go:343–371  ·  view source on GitHub ↗

countStarsInList counts the number of * expressions in a target list

(targets *ast.List)

Source from the content-addressed store, hash-verified

341
342// countStarsInList counts the number of * expressions in a target list
343func countStarsInList(targets *ast.List) int {
344 if targets == nil {
345 return 0
346 }
347 count := 0
348 for _, target := range targets.Items {
349 resTarget, ok := target.(*ast.ResTarget)
350 if !ok {
351 continue
352 }
353 if resTarget.Val == nil {
354 continue
355 }
356 colRef, ok := resTarget.Val.(*ast.ColumnRef)
357 if !ok {
358 continue
359 }
360 if colRef.Fields == nil {
361 continue
362 }
363 for _, field := range colRef.Fields.Items {
364 if _, ok := field.(*ast.A_Star); ok {
365 count++
366 break
367 }
368 }
369 }
370 return count
371}
372
373// countNonStarsInList counts the number of non-* expressions in a target list
374func countNonStarsInList(targets *ast.List) int {

Callers 1

rewriteTargetListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected