work on order by began
This commit is contained in:
17
parser.h
17
parser.h
@@ -34,6 +34,7 @@ namespace usql {
|
||||
save_table,
|
||||
drop_table,
|
||||
column_name,
|
||||
column_order,
|
||||
column_value,
|
||||
function,
|
||||
column_def,
|
||||
@@ -52,6 +53,15 @@ namespace usql {
|
||||
ColNameNode(const std::string col_name) : Node(NodeType::column_name), name(col_name) {}
|
||||
};
|
||||
|
||||
struct ColOrderNode : Node {
|
||||
std::string col_name;
|
||||
int col_index;
|
||||
bool ascending;
|
||||
|
||||
ColOrderNode(const std::string name, bool asc) : Node(NodeType::column_order), col_name(name), col_index(-1), ascending(asc) {}
|
||||
ColOrderNode(int index, bool asc) : Node(NodeType::column_name), col_name(""), col_index(index), ascending(asc) {}
|
||||
};
|
||||
|
||||
struct SelectColNode : Node {
|
||||
std::unique_ptr<Node> value;
|
||||
std::string name;
|
||||
@@ -216,9 +226,10 @@ namespace usql {
|
||||
std::string table_name;
|
||||
std::unique_ptr<std::vector<SelectColNode>> cols_names;
|
||||
std::unique_ptr<Node> where;
|
||||
std::vector<ColOrderNode> order_by;
|
||||
|
||||
SelectFromTableNode(std::string name, std::unique_ptr<std::vector<SelectColNode>> names, std::unique_ptr<Node> where_clause) :
|
||||
Node(NodeType::select_from), table_name(name), cols_names(std::move(names)), where(std::move(where_clause)) {}
|
||||
SelectFromTableNode(std::string name, std::unique_ptr<std::vector<SelectColNode>> names, std::unique_ptr<Node> where_clause, std::vector<ColOrderNode> orderby) :
|
||||
Node(NodeType::select_from), table_name(name), cols_names(std::move(names)), where(std::move(where_clause)), order_by(orderby) {}
|
||||
};
|
||||
|
||||
struct CreateTableAsSelectNode : Node {
|
||||
@@ -292,6 +303,8 @@ namespace usql {
|
||||
std::unique_ptr<Node> parse_update_table();
|
||||
|
||||
std::unique_ptr<Node> parse_where_clause();
|
||||
std::vector<ColOrderNode> parse_orderby_clause();
|
||||
|
||||
std::unique_ptr<Node> parse_operand_node();
|
||||
std::unique_ptr<Node> parse_value();
|
||||
RelationalOperatorType parse_relational_operator();
|
||||
|
||||
Reference in New Issue
Block a user