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

Function TestTSQL_TempTableIdentifiers

pkg/sql/tokenizer/tsql_test.go:49–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestTSQL_TempTableIdentifiers(t *testing.T) {
50 tkz := newSQLServerTokenizer(t)
51
52 tests := []struct {
53 name string
54 input string
55 want string
56 }{
57 {"local temp table", "#temp", "#temp"},
58 {"global temp table", "##global_temp", "##global_temp"},
59 {"temp table in SELECT", "SELECT * FROM #orders", "#orders"},
60 }
61
62 for _, tt := range tests {
63 t.Run(tt.name, func(t *testing.T) {
64 tokens := tokenize(t, tkz, tt.input)
65 // Find the identifier token with # prefix
66 found := false
67 for _, tok := range tokens {
68 if tok.Token.Value == tt.want {
69 if tok.Token.Type != models.TokenTypeIdentifier {
70 t.Errorf("expected TokenTypeIdentifier for %q, got %v", tt.want, tok.Token.Type)
71 }
72 found = true
73 break
74 }
75 }
76 if !found {
77 t.Errorf("did not find token with value %q in tokens:", tt.want)
78 for i, tok := range tokens {
79 t.Logf(" [%d] type=%v value=%q", i, tok.Token.Type, tok.Token.Value)
80 }
81 }
82 })
83 }
84}
85
86func TestTSQL_TempTableStandaloneHash(t *testing.T) {
87 // In SQL Server dialect, a standalone # (not followed by identifier) should still be TokenTypeSharp

Callers

nothing calls this directly

Calls 4

newSQLServerTokenizerFunction · 0.85
tokenizeFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected