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

Method expand

internal/compiler/expand.go:14–46  ·  view source on GitHub ↗
(qc *QueryCatalog, raw *ast.RawStmt)

Source from the content-addressed store, hash-verified

12)
13
14func (c *Compiler) expand(qc *QueryCatalog, raw *ast.RawStmt) ([]source.Edit, error) {
15 // Return early if there are no A_Star nodes to expand
16 stars := astutils.Search(raw, func(node ast.Node) bool {
17 _, ok := node.(*ast.A_Star)
18 return ok
19 })
20 if len(stars.Items) == 0 {
21 return nil, nil
22 }
23 list := astutils.Search(raw, func(node ast.Node) bool {
24 switch node.(type) {
25 case *ast.DeleteStmt:
26 case *ast.InsertStmt:
27 case *ast.SelectStmt:
28 case *ast.UpdateStmt:
29 default:
30 return false
31 }
32 return true
33 })
34 if len(list.Items) == 0 {
35 return nil, nil
36 }
37 var edits []source.Edit
38 for _, item := range list.Items {
39 edit, err := c.expandStmt(qc, raw, item)
40 if err != nil {
41 return nil, err
42 }
43 edits = append(edits, edit...)
44 }
45 return edits, nil
46}
47
48var validPostgresIdent = regexp.MustCompile(`^[a-z_][a-z0-9_$]*$`)
49

Callers 1

_analyzeQueryMethod · 0.95

Calls 2

expandStmtMethod · 0.95
SearchFunction · 0.92

Tested by

no test coverage detected