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

Function TestSelectStatementPositionMultiLine

pkg/sql/ast/positions_test.go:90–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestSelectStatementPositionMultiLine(t *testing.T) {
91 // Two statements on separate lines: verify positions differ
92 sql := "SELECT 1;\nSELECT 2"
93 tree := parseWithPositions(t, sql)
94
95 if len(tree.Statements) != 2 {
96 t.Fatalf("expected 2 statements, got %d", len(tree.Statements))
97 }
98
99 sel1, ok := tree.Statements[0].(*ast.SelectStatement)
100 if !ok {
101 t.Fatalf("expected *ast.SelectStatement for stmt 1, got %T", tree.Statements[0])
102 }
103 sel2, ok := tree.Statements[1].(*ast.SelectStatement)
104 if !ok {
105 t.Fatalf("expected *ast.SelectStatement for stmt 2, got %T", tree.Statements[1])
106 }
107
108 // Both must have non-zero positions
109 assertPos(t, "SELECT1.Pos", sel1.Pos)
110 assertPos(t, "SELECT2.Pos", sel2.Pos)
111
112 // The second SELECT should be on a later line than the first
113 if sel2.Pos.Line <= sel1.Pos.Line {
114 t.Errorf("second SELECT.Pos.Line (%d) should be > first (%d)",
115 sel2.Pos.Line, sel1.Pos.Line)
116 }
117}
118
119// -----------------------------------------------------------------------------
120// TestInsertStatementPosition verifies INSERT statement position

Callers

nothing calls this directly

Calls 4

parseWithPositionsFunction · 0.85
assertPosFunction · 0.85
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected