(t *testing.T)
| 424 | } |
| 425 | |
| 426 | func TestSelectWithLimitAndOffsetCommand(t *testing.T) { |
| 427 | input := "SELECT * FROM tableName ORDER BY colName1 DESC LIMIT 2 OFFSET 13;" |
| 428 | expectedLimitCommand := ast.LimitCommand{ |
| 429 | Token: token.Token{Type: token.LIMIT, Literal: "LIMIT"}, |
| 430 | Count: 2, |
| 431 | } |
| 432 | expectedOffsetCommand := ast.OffsetCommand{ |
| 433 | Token: token.Token{Type: token.OFFSET, Literal: "OFFSET"}, |
| 434 | Count: 13, |
| 435 | } |
| 436 | expectedTableName := "tableName" |
| 437 | expectedSpaces := []ast.Space{{ColumnName: token.Token{Type: token.ASTERISK, Literal: "*"}}} |
| 438 | |
| 439 | lexer := lexer.RunLexer(input) |
| 440 | parserInstance := New(lexer) |
| 441 | sequences, err := parserInstance.ParseSequence() |
| 442 | if err != nil { |
| 443 | t.Fatalf("Got error from parser: %s", err) |
| 444 | } |
| 445 | |
| 446 | if len(sequences.Commands) != 1 { |
| 447 | t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands)) |
| 448 | } |
| 449 | |
| 450 | selectCommand := sequences.Commands[0].(*ast.SelectCommand) |
| 451 | |
| 452 | if !testSelectStatement(t, selectCommand, expectedTableName, expectedSpaces, false) { |
| 453 | return |
| 454 | } |
| 455 | |
| 456 | if !selectCommand.HasLimitCommand() { |
| 457 | t.Fatalf("select command should have limit command") |
| 458 | } |
| 459 | if !selectCommand.HasOffsetCommand() { |
| 460 | t.Fatalf("select command should have offset command") |
| 461 | } |
| 462 | |
| 463 | testLimitCommands(t, expectedLimitCommand, selectCommand.LimitCommand) |
| 464 | testOffsetCommands(t, expectedOffsetCommand, selectCommand.OffsetCommand) |
| 465 | } |
| 466 | |
| 467 | func TestSelectWithDefaultInnerJoinCommand(t *testing.T) { |
| 468 | input := "SELECT tbl.one, tbl2.two FROM tbl JOIN tbl2 ON tbl.one EQUAL tbl2.one;" |
nothing calls this directly
no test coverage detected