@@ -24,6 +24,15 @@ func normalizeWhitespace(s string) string {
2424 return strings .TrimSpace (whitespaceRegex .ReplaceAllString (s , " " ))
2525}
2626
27+ // normalizeForFormat normalizes SQL for format comparison by collapsing
28+ // whitespace and stripping trailing semicolons. This allows comparing
29+ // formatted output regardless of whether the original had trailing semicolons.
30+ func normalizeForFormat (s string ) string {
31+ normalized := normalizeWhitespace (s )
32+ // Strip trailing semicolon if present
33+ return strings .TrimSuffix (normalized , ";" )
34+ }
35+
2736// checkSkipped runs skipped todo tests to see which ones now pass.
2837// Use with: go test ./parser -check-skipped -v
2938var checkSkipped = flag .Bool ("check-skipped" , false , "Run skipped todo tests to see which ones now pass" )
@@ -191,9 +200,9 @@ func TestParser(t *testing.T) {
191200 if ! metadata .TodoFormat || * checkFormat {
192201 formatted := parser .Format (stmts )
193202 expected := strings .TrimSpace (query )
194- // Compare with whitespace normalization to ignore formatting differences
195- formattedNorm := normalizeWhitespace (formatted )
196- expectedNorm := normalizeWhitespace (expected )
203+ // Compare with format normalization (whitespace + trailing semicolons)
204+ formattedNorm := normalizeForFormat (formatted )
205+ expectedNorm := normalizeForFormat (expected )
197206 if formattedNorm != expectedNorm {
198207 if metadata .TodoFormat {
199208 if * checkFormat {
0 commit comments