From e886ae16443ccf43bc3e50ddc74905d2f7e7eb35 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 22 Oct 2014 17:46:52 +0200 Subject: [PATCH] added special expression type for star selector --- src/bison/bison_parser.y | 2 +- src/lib/Expr.h | 3 +++ src/sql_tests.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bison/bison_parser.y b/src/bison/bison_parser.y index e746f11..acc6335 100644 --- a/src/bison/bison_parser.y +++ b/src/bison/bison_parser.y @@ -138,7 +138,7 @@ select_statement: select_list: - '*' { $$ = new List(makeColumnRef("*")); } + '*' { $$ = new List(new Expr(eExprStar)); } | expr_list; diff --git a/src/lib/Expr.h b/src/lib/Expr.h index 99d6c5e..8e36e1e 100644 --- a/src/lib/Expr.h +++ b/src/lib/Expr.h @@ -7,6 +7,7 @@ typedef enum { eExprLiteralFloat, eExprLiteralString, + eExprStar, eExprColumnRef, eExprFunctionRef, eExprPredicate @@ -15,6 +16,8 @@ typedef enum { typedef struct Expr Expr; struct Expr { + Expr(EExprType type) : type(type) {}; + EExprType type; Expr* expr; diff --git a/src/sql_tests.cpp b/src/sql_tests.cpp index 0e7da57..18cd798 100644 --- a/src/sql_tests.cpp +++ b/src/sql_tests.cpp @@ -56,7 +56,7 @@ void SelectTest2() { SelectStatement* select = (SelectStatement*) stmt; ASSERT(select->select_list->size() == 1); - ASSERT_STR(select->select_list->at(0)->name, "*"); + ASSERT(select->select_list->at(0)->type == eExprStar); ASSERT(select->from_table != NULL); ASSERT(select->from_table->type == eTableSelect);