Skip to content

Commit

Permalink
Add Debug to AST builder nodes (gluesql#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
panarch committed Dec 2, 2022
1 parent b92459d commit 307275c
Show file tree
Hide file tree
Showing 41 changed files with 137 additions and 51 deletions.
1 change: 1 addition & 0 deletions core/src/ast_builder/alter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use {
},
};

#[derive(Clone, Debug)]
pub struct AlterTableNode {
table_name: String,
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum AssignmentNode<'a> {
Expr(String, ExprNode<'a>),
Text(String),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/column_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
translate::translate_column_def,
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum ColumnDefNode {
Text(String),
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/column_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
translate::translate_idents,
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum ColumnList {
Text(String),
Columns(Vec<String>),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
crate::{ast::Statement, ast_builder::ColumnDefNode, result::Result},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct CreateTableNode {
table_name: String,
if_not_exists: bool,
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
translate::translate_data_type,
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum DataTypeNode {
DataType(DataType),
Text(String),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct DeleteNode<'a> {
table_name: String,
filter_expr: Option<ExprNode<'a>>,
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/drop_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
crate::{ast::Statement, result::Result},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct DropTableNode {
table_name: String,
if_exists: bool,
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/expr/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum AggregateNode<'a> {
Count(CountArgExprNode<'a>),
Sum(ExprNode<'a>),
Expand All @@ -19,7 +19,7 @@ pub enum AggregateNode<'a> {
Stdev(ExprNode<'a>),
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum CountArgExprNode<'a> {
Text(String),
Expr(ExprNode<'a>),
Expand Down
2 changes: 2 additions & 0 deletions core/src/ast_builder/expr/case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub fn case() -> CaseNode<'static> {
CaseNode { operand: None }
}

#[derive(Clone, Debug)]
pub struct CaseNode<'a> {
operand: Option<Box<ExprNode<'a>>>,
}
Expand All @@ -29,6 +30,7 @@ impl<'a> CaseNode<'a> {
}
}

#[derive(Clone, Debug)]
pub struct WhenThenNode<'a> {
prev_node: CaseNode<'a>,
when_then: Vec<(ExprNode<'a>, ExprNode<'a>)>,
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum FunctionNode<'a> {
Abs(ExprNode<'a>),
Upper(ExprNode<'a>),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/expr/in_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum InListNode<'a> {
InList(Vec<ExprNode<'a>>),
Query(Box<QueryNode<'a>>),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use {
std::borrow::Cow,
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum ExprNode<'a> {
Expr(Cow<'a, Expr>),
SqlExpr(Cow<'a, str>),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/expr/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
std::{borrow::Cow, str::FromStr},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum NumericNode<'a> {
I8(i8),
I16(i16),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/expr_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
std::borrow::Cow,
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum ExprList<'a> {
Text(Cow<'a, str>),
Exprs(Cow<'a, [ExprNode<'a>]>),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {

use super::OrderByExprNode;

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct CreateIndexNode<'a> {
name: String,
table_name: String,
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct InsertNode {
table_name: String,
columns: Option<ColumnList>,
Expand Down Expand Up @@ -42,7 +42,7 @@ impl InsertNode {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct InsertSourceNode<'a> {
insert_node: InsertNode,
source: QueryNode<'a>,
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/order_by_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum OrderByExprNode<'a> {
Text(String),
Expr(ExprNode<'a>),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/order_by_expr_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum OrderByExprList<'a> {
Text(String),
OrderByExprs(Vec<OrderByExprNode<'a>>),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum QueryNode<'a> {
Text(String),
Values(Vec<ExprList<'a>>),
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/select/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum PrevNode<'a> {
Select(SelectNode<'a>),
Join(Box<JoinNode<'a>>),
Expand Down Expand Up @@ -52,7 +52,7 @@ impl<'a> From<SelectNode<'a>> for PrevNode<'a> {
PrevNode::Select(node)
}
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct FilterNode<'a> {
prev_node: PrevNode<'a>,
filter_expr: ExprNode<'a>,
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/select/group_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum PrevNode<'a> {
Select(SelectNode<'a>),
Join(Box<JoinNode<'a>>),
Expand Down Expand Up @@ -61,7 +61,7 @@ impl<'a> From<FilterNode<'a>> for PrevNode<'a> {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct GroupByNode<'a> {
prev_node: PrevNode<'a>,
expr_list: ExprList<'a>,
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/select/having.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum PrevNode<'a> {
GroupBy(GroupByNode<'a>),
}
Expand All @@ -28,7 +28,7 @@ impl<'a> From<GroupByNode<'a>> for PrevNode<'a> {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct HavingNode<'a> {
prev_node: PrevNode<'a>,
expr: ExprNode<'a>,
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/select/join/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct HashJoinNode<'a> {
join_node: JoinNode<'a>,
key_expr: ExprNode<'a>,
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/select/join/join_constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum PrevNode<'a> {
Join(Box<JoinNode<'a>>),
HashJoin(Box<HashJoinNode<'a>>),
Expand All @@ -39,7 +39,7 @@ impl<'a> From<HashJoinNode<'a>> for PrevNode<'a> {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct JoinConstraintNode<'a> {
prev_node: PrevNode<'a>,
expr: ExprNode<'a>,
Expand Down
2 changes: 1 addition & 1 deletion core/src/ast_builder/select/join/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
ast_builder::select::NodeData,
};

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub enum JoinOperatorType {
Inner,
Left,
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/select/join/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum PrevNode<'a> {
Select(SelectNode<'a>),
Join(Box<JoinNode<'a>>),
Expand Down Expand Up @@ -55,7 +55,7 @@ impl<'a> From<HashJoinNode<'a>> for PrevNode<'a> {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct JoinNode<'a> {
prev_node: PrevNode<'a>,
relation: TableFactor,
Expand Down
4 changes: 2 additions & 2 deletions core/src/ast_builder/select/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
},
};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum PrevNode<'a> {
Select(SelectNode<'a>),
GroupBy(GroupByNode<'a>),
Expand Down Expand Up @@ -85,7 +85,7 @@ impl<'a> From<OrderByNode<'a>> for PrevNode<'a> {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct LimitNode<'a> {
prev_node: PrevNode<'a>,
expr: ExprNode<'a>,
Expand Down

0 comments on commit 307275c

Please sign in to comment.