MCPcopy Create free account
hub / github.com/araddon/qlbridge / TestLexSqlSelect

Function TestLexSqlSelect

lex/dialect_sql_test.go:301–360  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

299}
300
301func TestLexSqlSelect(t *testing.T) {
302 /*
303 SELECT column1, column2, column3, ...
304 INTO newtable [IN externaldb]
305 FROM oldtable
306 WHERE condition;
307 */
308 verifyTokens(t, `SELECT a, tolower(b) AS b INTO newtable FROM oldtable WHERE a != "hello";`,
309 []Token{
310 tv(TokenSelect, "SELECT"),
311 tv(TokenIdentity, "a"),
312 tv(TokenComma, ","),
313 tv(TokenUdfExpr, "tolower"),
314 tv(TokenLeftParenthesis, "("),
315 tv(TokenIdentity, "b"),
316 tv(TokenRightParenthesis, ")"),
317 tv(TokenAs, "AS"),
318 tv(TokenIdentity, "b"),
319 tv(TokenInto, "INTO"),
320 tv(TokenTable, "newtable"),
321 tv(TokenFrom, "FROM"),
322 tv(TokenIdentity, "oldtable"),
323 tv(TokenWhere, "WHERE"),
324 tv(TokenIdentity, "a"),
325 tv(TokenNE, "!="),
326 tv(TokenValue, "hello"),
327 })
328 verifyTokens(t, `SELECT a FROM tbl LIMIT 1";`,
329 []Token{
330 tv(TokenSelect, "SELECT"),
331 tv(TokenIdentity, "a"),
332 tv(TokenFrom, "FROM"),
333 tv(TokenIdentity, "tbl"),
334 tv(TokenLimit, "LIMIT"),
335 tv(TokenInteger, "1"),
336 })
337 verifyTokens(t, `SELECT a FROM tbl LIMIT 1, 100";`,
338 []Token{
339 tv(TokenSelect, "SELECT"),
340 tv(TokenIdentity, "a"),
341 tv(TokenFrom, "FROM"),
342 tv(TokenIdentity, "tbl"),
343 tv(TokenLimit, "LIMIT"),
344 tv(TokenInteger, "1"),
345 tv(TokenComma, ","),
346 tv(TokenInteger, "100"),
347 })
348 // LIMIT 1000 OFFSET 100
349 verifyTokens(t, `SELECT a FROM tbl LIMIT 1 OFFSET 100";`,
350 []Token{
351 tv(TokenSelect, "SELECT"),
352 tv(TokenIdentity, "a"),
353 tv(TokenFrom, "FROM"),
354 tv(TokenIdentity, "tbl"),
355 tv(TokenLimit, "LIMIT"),
356 tv(TokenInteger, "1"),
357 tv(TokenOffset, "OFFSET"),
358 tv(TokenInteger, "100"),

Callers

nothing calls this directly

Calls 2

verifyTokensFunction · 0.70
tvFunction · 0.70

Tested by

no test coverage detected