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

Function TestClickHouseFinalRoundtrip

pkg/sql/parser/clickhouse_test.go:210–227  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

208}
209
210func TestClickHouseFinalRoundtrip(t *testing.T) {
211 input := `SELECT * FROM orders FINAL`
212 tree, err := parser.ParseWithDialect(input, keywords.DialectClickHouse)
213 if err != nil {
214 t.Fatalf("unexpected parse error: %v", err)
215 }
216 if len(tree.Statements) == 0 {
217 t.Fatal("expected at least one statement")
218 }
219 sel, ok := tree.Statements[0].(*ast.SelectStatement)
220 if !ok {
221 t.Fatalf("expected SelectStatement, got %T", tree.Statements[0])
222 }
223 got := sel.SQL()
224 if !containsFINAL(got) {
225 t.Errorf("SQL() round-trip output does not contain FINAL; got: %q", got)
226 }
227}
228
229// containsFINAL reports whether s contains the uppercase keyword FINAL as a
230// whole word. A simple strings.Contains is sufficient because SQL() always

Callers

nothing calls this directly

Calls 5

ParseWithDialectFunction · 0.92
containsFINALFunction · 0.85
FatalfMethod · 0.65
ErrorfMethod · 0.65
SQLMethod · 0.45

Tested by

no test coverage detected