Fix order of table_ref
This commit is contained in:
parent
1425deb75d
commit
a578842117
File diff suppressed because it is too large
Load Diff
|
@ -793,7 +793,7 @@ in_expr:
|
|||
| operand NOT IN '(' select_no_paren ')' { $$ = Expr::makeOpUnary(kOpNot, Expr::makeInOperator($1, $5)); }
|
||||
;
|
||||
|
||||
// CASE grammar based on: flex & bison by John Levine
|
||||
// CASE grammar based on: flex & bison by John Levine
|
||||
// https://www.safaribooksonline.com/library/view/flex-bison/9780596805418/ch04.html#id352665
|
||||
case_expr:
|
||||
CASE expr case_list END { $$ = Expr::makeCase($2, $3, nullptr); }
|
||||
|
@ -884,10 +884,10 @@ param_expr:
|
|||
******************************/
|
||||
table_ref:
|
||||
table_ref_atomic
|
||||
| table_ref_atomic ',' table_ref_commalist {
|
||||
$3->push_back($1);
|
||||
| table_ref_commalist ',' table_ref_atomic {
|
||||
$1->push_back($3);
|
||||
auto tbl = new TableRef(kTableCrossProduct);
|
||||
tbl->list = $3;
|
||||
tbl->list = $1;
|
||||
$$ = tbl;
|
||||
}
|
||||
;
|
||||
|
|
|
@ -325,3 +325,25 @@ TEST(SelectJoin) {
|
|||
ASSERT_STREQ(inner_join->condition->expr2->table, "City");
|
||||
ASSERT_STREQ(inner_join->condition->expr2->name, "id");
|
||||
}
|
||||
|
||||
|
||||
TEST(SelectColumnOrder) {
|
||||
TEST_PARSE_SINGLE_SQL(
|
||||
"SELECT *\
|
||||
FROM a,\
|
||||
(SELECT a AS b FROM a) b,\
|
||||
(SELECT a AS c FROM a) c,\
|
||||
(SELECT a AS d FROM a) d;",
|
||||
kStmtSelect,
|
||||
SelectStatement,
|
||||
result,
|
||||
stmt);
|
||||
|
||||
ASSERT_EQ(stmt->fromTable->list->size(), 4);
|
||||
|
||||
// Make sure the order of the table list is corrects
|
||||
ASSERT_STREQ(stmt->fromTable->list->at(0)->name, "a");
|
||||
ASSERT_STREQ(stmt->fromTable->list->at(1)->alias, "b");
|
||||
ASSERT_STREQ(stmt->fromTable->list->at(2)->alias, "c");
|
||||
ASSERT_STREQ(stmt->fromTable->list->at(3)->alias, "d");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue