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

Function tokenizeSQL

pkg/sql/parser/context_test.go:30–46  ·  view source on GitHub ↗

Helper function to tokenize SQL for tests. Returns []token.Token for compatibility with ParseContext (backward-compat shim).

(t *testing.T, sql string)

Source from the content-addressed store, hash-verified

28// Helper function to tokenize SQL for tests.
29// Returns []token.Token for compatibility with ParseContext (backward-compat shim).
30func tokenizeSQL(t *testing.T, sql string) []token.Token {
31 t.Helper()
32 tkz := tokenizer.GetTokenizer()
33 defer tokenizer.PutTokenizer(tkz)
34
35 spanTokens, err := tkz.Tokenize([]byte(sql))
36 if err != nil {
37 t.Fatalf("Failed to tokenize SQL: %v", err)
38 }
39
40 // Wrap models.TokenWithSpan → token.Token for the ParseContext shim.
41 result := make([]token.Token, len(spanTokens))
42 for i, st := range spanTokens {
43 result[i] = token.Token{Type: st.Token.Type, Literal: st.Token.Value}
44 }
45 return result
46}
47
48// TestParseContext_BasicSuccess verifies that ParseContext works for valid SQL
49func TestParseContext_BasicSuccess(t *testing.T) {

Calls 5

GetTokenizerFunction · 0.92
PutTokenizerFunction · 0.92
TokenizeMethod · 0.80
HelperMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected