(t *testing.T)
| 621 | } |
| 622 | |
| 623 | func TestSelectWithFullJoinCommand(t *testing.T) { |
| 624 | input := "SELECT tbl.one, tbl2.two FROM tbl FULL JOIN tbl2 ON tbl.one EQUAL tbl2.one;" |
| 625 | expectedJoinCommand := ast.JoinCommand{ |
| 626 | Token: token.Token{Type: token.JOIN, Literal: "JOIN"}, |
| 627 | Name: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl2"}}, |
| 628 | JoinType: token.Token{Type: token.FULL, Literal: "FULL"}, |
| 629 | Expression: ast.ConditionExpression{ |
| 630 | Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl.one"}}, |
| 631 | Right: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl2.one"}}, |
| 632 | Condition: token.Token{Type: token.EQUAL, Literal: "EQUAL"}, |
| 633 | }, |
| 634 | } |
| 635 | expectedTableName := "tbl" |
| 636 | expectedSpaces := []ast.Space{{ColumnName: token.Token{Type: token.IDENT, Literal: "tbl.one"}}, {ColumnName: token.Token{Type: token.IDENT, Literal: "tbl2.two"}}} |
| 637 | |
| 638 | lexer := lexer.RunLexer(input) |
| 639 | parserInstance := New(lexer) |
| 640 | sequences, err := parserInstance.ParseSequence() |
| 641 | if err != nil { |
| 642 | t.Fatalf("Got error from parser: %s", err) |
| 643 | } |
| 644 | |
| 645 | if len(sequences.Commands) != 1 { |
| 646 | t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands)) |
| 647 | } |
| 648 | |
| 649 | selectCommand := sequences.Commands[0].(*ast.SelectCommand) |
| 650 | |
| 651 | if !testSelectStatement(t, selectCommand, expectedTableName, expectedSpaces, false) { |
| 652 | return |
| 653 | } |
| 654 | |
| 655 | if !selectCommand.HasJoinCommand() { |
| 656 | t.Fatalf("select command should have join command") |
| 657 | } |
| 658 | |
| 659 | testJoinCommands(t, expectedJoinCommand, *selectCommand.JoinCommand) |
| 660 | } |
| 661 | |
| 662 | func TestSelectWithAggregateFunctions(t *testing.T) { |
| 663 | input := "SELECT MIN(colOne), MAX(colOne), COUNT(*), COUNT(colOne), SUM(colOne), AVG(colOne) FROM tbl;" |
nothing calls this directly
no test coverage detected