MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / countNonStarsInList

Function countNonStarsInList

internal/x/expander/expander.go:374–410  ·  view source on GitHub ↗

countNonStarsInList counts the number of non-* expressions in a target list

(targets *ast.List)

Source from the content-addressed store, hash-verified

372
373// countNonStarsInList counts the number of non-* expressions in a target list
374func countNonStarsInList(targets *ast.List) int {
375 if targets == nil {
376 return 0
377 }
378 count := 0
379 for _, target := range targets.Items {
380 resTarget, ok := target.(*ast.ResTarget)
381 if !ok {
382 count++
383 continue
384 }
385 if resTarget.Val == nil {
386 count++
387 continue
388 }
389 colRef, ok := resTarget.Val.(*ast.ColumnRef)
390 if !ok {
391 count++
392 continue
393 }
394 if colRef.Fields == nil {
395 count++
396 continue
397 }
398 isStar := false
399 for _, field := range colRef.Fields.Items {
400 if _, ok := field.(*ast.A_Star); ok {
401 isStar = true
402 break
403 }
404 }
405 if !isStar {
406 count++
407 }
408 }
409 return count
410}
411
412// rewriteTargetList replaces * in a target list with explicit column references
413func rewriteTargetList(targets *ast.List, columns []string) *ast.List {

Callers 1

rewriteTargetListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected