--------------------------------------------------------------------------- OPT-001: SELECT * Detection ---------------------------------------------------------------------------
(t *testing.T)
| 47 | // --------------------------------------------------------------------------- |
| 48 | |
| 49 | func 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 |
nothing calls this directly
no test coverage detected