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

Function TestTSQL_GlobalVariables

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

Source from the content-addressed store, hash-verified

112}
113
114func TestTSQL_GlobalVariables(t *testing.T) {
115 tkz := newSQLServerTokenizer(t)
116
117 tests := []struct {
118 name string
119 input string
120 want string
121 }{
122 {"@@ROWCOUNT", "@@ROWCOUNT", "@@ROWCOUNT"},
123 {"@@IDENTITY", "@@IDENTITY", "@@IDENTITY"},
124 {"@@ERROR", "SELECT @@ERROR", "@@ERROR"},
125 {"@@VERSION", "@@VERSION", "@@VERSION"},
126 }
127
128 for _, tt := range tests {
129 t.Run(tt.name, func(t *testing.T) {
130 tokens := tokenize(t, tkz, tt.input)
131 found := false
132 for _, tok := range tokens {
133 if tok.Token.Value == tt.want {
134 if tok.Token.Type != models.TokenTypeIdentifier {
135 t.Errorf("expected TokenTypeIdentifier for %q, got %v", tt.want, tok.Token.Type)
136 }
137 found = true
138 break
139 }
140 }
141 if !found {
142 t.Errorf("did not find token with value %q in tokens:", tt.want)
143 for i, tok := range tokens {
144 t.Logf(" [%d] type=%v value=%q", i, tok.Token.Type, tok.Token.Value)
145 }
146 }
147 })
148 }
149}
150
151func TestTSQL_AtAtStillWorksInPostgreSQL(t *testing.T) {
152 // In PostgreSQL dialect, @@ should still be TokenTypeAtAt

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