(t *testing.T)
| 504 | } |
| 505 | |
| 506 | func TestSelectWithInnerJoinCommand(t *testing.T) { |
| 507 | input := "SELECT tbl.one, tbl2.two FROM tbl INNER JOIN tbl2 ON tbl.one EQUAL tbl2.one;" |
| 508 | expectedJoinCommand := ast.JoinCommand{ |
| 509 | Token: token.Token{Type: token.JOIN, Literal: "JOIN"}, |
| 510 | Name: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl2"}}, |
| 511 | JoinType: token.Token{Type: token.INNER, Literal: "INNER"}, |
| 512 | Expression: ast.ConditionExpression{ |
| 513 | Left: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl.one"}}, |
| 514 | Right: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "tbl2.one"}}, |
| 515 | Condition: token.Token{Type: token.EQUAL, Literal: "EQUAL"}, |
| 516 | }, |
| 517 | } |
| 518 | expectedTableName := "tbl" |
| 519 | expectedSpace := []ast.Space{{ColumnName: token.Token{Type: token.IDENT, Literal: "tbl.one"}}, {ColumnName: token.Token{Type: token.IDENT, Literal: "tbl2.two"}}} |
| 520 | |
| 521 | lexer := lexer.RunLexer(input) |
| 522 | parserInstance := New(lexer) |
| 523 | sequences, err := parserInstance.ParseSequence() |
| 524 | if err != nil { |
| 525 | t.Fatalf("Got error from parser: %s", err) |
| 526 | } |
| 527 | |
| 528 | if len(sequences.Commands) != 1 { |
| 529 | t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands)) |
| 530 | } |
| 531 | |
| 532 | selectCommand := sequences.Commands[0].(*ast.SelectCommand) |
| 533 | |
| 534 | if !testSelectStatement(t, selectCommand, expectedTableName, expectedSpace, false) { |
| 535 | return |
| 536 | } |
| 537 | |
| 538 | if !selectCommand.HasJoinCommand() { |
| 539 | t.Fatalf("select command should have join command") |
| 540 | } |
| 541 | |
| 542 | testJoinCommands(t, expectedJoinCommand, *selectCommand.JoinCommand) |
| 543 | } |
| 544 | |
| 545 | func TestSelectWithLeftJoinCommand(t *testing.T) { |
| 546 | input := "SELECT tbl.one, tbl2.two FROM tbl LEFT JOIN tbl2 ON tbl.one EQUAL tbl2.one;" |
nothing calls this directly
no test coverage detected