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

Function TestTopVerification

pkg/sql/parser/verify_top_test.go:33–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestTopVerification(t *testing.T) {
34 // Test 1: sqlserver dialect - must succeed
35 err := parseTopSQL(t, "SELECT TOP 10 id FROM users", "sqlserver")
36 if err != nil {
37 t.Errorf("BLOCKER FAIL (sqlserver): %v", err)
38 } else {
39 t.Log("PASS: SELECT TOP 10 succeeds with sqlserver dialect")
40 }
41
42 // Test 2: Oracle dialect - must fail with correct message (ROWNUM, not LIMIT)
43 err = parseTopSQL(t, "SELECT TOP 10 id FROM users", "oracle")
44 if err == nil {
45 t.Error("FAIL: Oracle should reject TOP")
46 } else if strings.Contains(err.Error(), "ROWNUM") {
47 t.Logf("PASS (oracle): %v", err)
48 } else {
49 t.Errorf("FAIL: Oracle error should mention ROWNUM, got: %v", err)
50 }
51
52 // Test 3: mysql dialect - must fail with correct message (LIMIT/OFFSET)
53 err = parseTopSQL(t, "SELECT TOP 10 id FROM users", "mysql")
54 if err == nil {
55 t.Error("FAIL: MySQL should reject TOP")
56 } else if strings.Contains(err.Error(), "LIMIT") {
57 t.Logf("PASS (mysql): %v", err)
58 } else {
59 t.Errorf("FAIL: MySQL error should mention LIMIT, got: %v", err)
60 }
61}

Callers

nothing calls this directly

Calls 3

parseTopSQLFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected