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

Function TestSelectStarRule

pkg/advisor/optimizer_test.go:49–83  ·  view source on GitHub ↗

--------------------------------------------------------------------------- OPT-001: SELECT * Detection ---------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

47// ---------------------------------------------------------------------------
48
49func TestSelectStarRule(t *testing.T) {
50 opt := New()
51
52 tests := []struct {
53 name string
54 sql string
55 wantHit bool
56 }{
57 {
58 name: "SELECT * triggers suggestion",
59 sql: "SELECT * FROM users",
60 wantHit: true,
61 },
62 {
63 name: "Named columns do not trigger",
64 sql: "SELECT id, name FROM users",
65 wantHit: false,
66 },
67 {
68 name: "COUNT(*) does not trigger",
69 sql: "SELECT COUNT(*) FROM users",
70 wantHit: false,
71 },
72 }
73
74 for _, tt := range tests {
75 t.Run(tt.name, func(t *testing.T) {
76 result := mustAnalyze(t, opt, tt.sql)
77 got := hasSuggestion(result, "OPT-001")
78 if got != tt.wantHit {
79 t.Errorf("hasSuggestion(OPT-001) = %v, want %v for SQL %q", got, tt.wantHit, tt.sql)
80 }
81 })
82 }
83}
84
85// ---------------------------------------------------------------------------
86// OPT-002: Missing WHERE Clause

Callers

nothing calls this directly

Calls 5

mustAnalyzeFunction · 0.85
hasSuggestionFunction · 0.85
RunMethod · 0.80
NewFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected