MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestExtractColumns

Function TestExtractColumns

pkg/cbinding/cbinding_test.go:118–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestExtractColumns(t *testing.T) {
119 tree, err := gosqlx.Parse("SELECT name, email FROM users WHERE active = true")
120 if err != nil {
121 t.Fatalf("parse failed: %v", err)
122 }
123
124 columns := gosqlx.ExtractColumns(tree)
125 if len(columns) == 0 {
126 t.Fatal("expected at least one column, got none")
127 }
128
129 colSet := make(map[string]bool)
130 for _, col := range columns {
131 colSet[col] = true
132 }
133 if !colSet["name"] {
134 t.Errorf("expected 'name' in columns, got: %v", columns)
135 }
136 if !colSet["email"] {
137 t.Errorf("expected 'email' in columns, got: %v", columns)
138 }
139}
140
141func TestExtractFunctions(t *testing.T) {
142 tree, err := gosqlx.Parse("SELECT COUNT(*), SUM(amount) FROM orders")

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.92
ExtractColumnsFunction · 0.92
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected