(t *testing.T)
| 582 | } |
| 583 | |
| 584 | func TestSelectWithRightJoinCommand(t *testing.T) { |
| 585 | input := "SELECT tbl.one, tbl2.two FROM tbl RIGHT JOIN tbl2 ON tbl.one EQUAL tbl2.one;" |
| 586 | expectedJoinCommand := ast.JoinCommand{ |
| 587 | Token: token.Token{Type: token.JOIN, Literal: "JOIN"}, |
| 588 | Name: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl2"}}, |
| 589 | JoinType: token.Token{Type: token.RIGHT, Literal: "RIGHT"}, |
| 590 | Expression: ast.ConditionExpression{ |
| 591 | Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl.one"}}, |
| 592 | Right: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl2.one"}}, |
| 593 | Condition: token.Token{Type: token.EQUAL, Literal: "EQUAL"}, |
| 594 | }, |
| 595 | } |
| 596 | expectedTableName := "tbl" |
| 597 | expectedSpaces := []ast.Space{{ColumnName: token.Token{Type: token.IDENT, Literal: "tbl.one"}}, {ColumnName: token.Token{Type: token.IDENT, Literal: "tbl2.two"}}} |
| 598 | |
| 599 | lexer := lexer.RunLexer(input) |
| 600 | parserInstance := New(lexer) |
| 601 | sequences, err := parserInstance.ParseSequence() |
| 602 | if err != nil { |
| 603 | t.Fatalf("Got error from parser: %s", err) |
| 604 | } |
| 605 | |
| 606 | if len(sequences.Commands) != 1 { |
| 607 | t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands)) |
| 608 | } |
| 609 | |
| 610 | selectCommand := sequences.Commands[0].(*ast.SelectCommand) |
| 611 | |
| 612 | if !testSelectStatement(t, selectCommand, expectedTableName, expectedSpaces, false) { |
| 613 | return |
| 614 | } |
| 615 | |
| 616 | if !selectCommand.HasJoinCommand() { |
| 617 | t.Fatalf("select command should have join command") |
| 618 | } |
| 619 | |
| 620 | testJoinCommands(t, expectedJoinCommand, *selectCommand.JoinCommand) |
| 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;" |
nothing calls this directly
no test coverage detected