MCPcopy Create free account
hub / github.com/LissaGreense/GO4SQL / TestParseWhereCommand

Function TestParseWhereCommand

parser/parser_test.go:156–244  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestParseWhereCommand(t *testing.T) {
157 firstExpression := ast.ConditionExpression{
158 Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "colName1"}},
159 Right: ast.Anonymitifier{Token: token.Token{Type: token.IDENT, Literal: "fda"}},
160 Condition: token.Token{Type: token.EQUAL, Literal: "EQUAL"},
161 }
162
163 secondExpression := ast.ConditionExpression{
164 Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "colName2"}},
165 Right: ast.Anonymitifier{Token: token.Token{Type: token.LITERAL, Literal: "6462389"}},
166 Condition: token.Token{Type: token.EQUAL, Literal: "EQUAL"},
167 }
168
169 thirdExpression := ast.ContainExpression{
170 Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "colName3"}},
171 Right: []ast.Anonymitifier{
172 {Token: token.Token{Type: token.LITERAL, Literal: "1"}},
173 {Token: token.Token{Type: token.LITERAL, Literal: "2"}},
174 },
175 Contains: true,
176 }
177
178 fourthExpression := ast.ContainExpression{
179 Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "colName4"}},
180 Right: []ast.Anonymitifier{
181 {Token: token.Token{Type: token.IDENT, Literal: "one"}},
182 {Token: token.Token{Type: token.IDENT, Literal: "two"}},
183 },
184 Contains: false,
185 }
186
187 fifthExpression := ast.ConditionExpression{
188 Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "colName5"}},
189 Right: ast.Anonymitifier{Token: token.Token{Type: token.NULL, Literal: "NULL"}},
190 Condition: token.Token{Type: token.EQUAL, Literal: "EQUAL"},
191 }
192
193 tests := []struct {
194 input string
195 expectedExpression ast.Expression
196 }{
197 {
198 input: "SELECT * FROM TBL WHERE colName1 EQUAL 'fda';",
199 expectedExpression: firstExpression,
200 },
201 {
202 input: "SELECT * FROM TBL WHERE colName2 EQUAL 6462389;",
203 expectedExpression: secondExpression,
204 },
205 {
206 input: "SELECT * FROM TBL WHERE colName3 IN (1, 2);",
207 expectedExpression: thirdExpression,
208 },
209 {
210 input: "SELECT * FROM TBL WHERE colName4 NOTIN ('one', 'two');",
211 expectedExpression: fourthExpression,
212 },
213 {

Callers

nothing calls this directly

Calls 5

RunLexerFunction · 0.92
whereStatementIsValidFunction · 0.85
ParseSequenceMethod · 0.80
NewFunction · 0.70
HasWhereCommandMethod · 0.45

Tested by

no test coverage detected