mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 15:04:04 +00:00
Don't Box<ASTNode> in SQLStatement
This used to be needed when it was a variant in the ASTNode enum itself.
This commit is contained in:
parent
3619e89e9c
commit
c5bbfc33fd
4 changed files with 13 additions and 13 deletions
|
@ -164,14 +164,14 @@ pub enum SQLStatement {
|
|||
/// Column assignments
|
||||
assignments: Vec<SQLAssignment>,
|
||||
/// WHERE
|
||||
selection: Option<Box<ASTNode>>,
|
||||
selection: Option<ASTNode>,
|
||||
},
|
||||
/// DELETE
|
||||
SQLDelete {
|
||||
/// FROM
|
||||
table_name: SQLObjectName,
|
||||
/// WHERE
|
||||
selection: Option<Box<ASTNode>>,
|
||||
selection: Option<ASTNode>,
|
||||
},
|
||||
/// CREATE TABLE
|
||||
SQLCreateTable {
|
||||
|
@ -264,7 +264,7 @@ impl ToString for SQLStatement {
|
|||
);
|
||||
}
|
||||
if let Some(selection) = selection {
|
||||
s += &format!(" WHERE {}", selection.as_ref().to_string());
|
||||
s += &format!(" WHERE {}", selection.to_string());
|
||||
}
|
||||
s
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ impl ToString for SQLStatement {
|
|||
} => {
|
||||
let mut s = format!("DELETE FROM {}", table_name.to_string());
|
||||
if let Some(selection) = selection {
|
||||
s += &format!(" WHERE {}", selection.as_ref().to_string());
|
||||
s += &format!(" WHERE {}", selection.to_string());
|
||||
}
|
||||
s
|
||||
}
|
||||
|
@ -308,12 +308,12 @@ impl ToString for SQLObjectName {
|
|||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct SQLAssignment {
|
||||
id: SQLIdent,
|
||||
value: Box<ASTNode>,
|
||||
value: ASTNode,
|
||||
}
|
||||
|
||||
impl ToString for SQLAssignment {
|
||||
fn to_string(&self) -> String {
|
||||
format!("SET {} = {}", self.id, self.value.as_ref().to_string())
|
||||
format!("SET {} = {}", self.id, self.value.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ pub struct SQLColumnDef {
|
|||
pub data_type: SQLType,
|
||||
pub is_primary: bool,
|
||||
pub is_unique: bool,
|
||||
pub default: Option<Box<ASTNode>>,
|
||||
pub default: Option<ASTNode>,
|
||||
pub allow_null: bool,
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ impl ToString for SQLColumnDef {
|
|||
s += " UNIQUE";
|
||||
}
|
||||
if let Some(ref default) = self.default {
|
||||
s += &format!(" DEFAULT {}", default.as_ref().to_string());
|
||||
s += &format!(" DEFAULT {}", default.to_string());
|
||||
}
|
||||
if !self.allow_null {
|
||||
s += " NOT NULL";
|
||||
|
|
|
@ -553,7 +553,7 @@ impl Parser {
|
|||
let is_unique = self.parse_keyword("UNIQUE");
|
||||
let default = if self.parse_keyword("DEFAULT") {
|
||||
let expr = self.parse_default_expr(0)?;
|
||||
Some(Box::new(expr))
|
||||
Some(expr)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -1104,7 +1104,7 @@ impl Parser {
|
|||
self.expect_keyword("FROM")?;
|
||||
let table_name = self.parse_object_name()?;
|
||||
let selection = if self.parse_keyword("WHERE") {
|
||||
Some(Box::new(self.parse_expr()?))
|
||||
Some(self.parse_expr()?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ fn parse_where_delete_statement() {
|
|||
op: Eq,
|
||||
right: Box::new(SQLValue(Value::Long(5))),
|
||||
},
|
||||
*selection.unwrap(),
|
||||
selection.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ fn parse_create_table_from_pg_dump() {
|
|||
|
||||
let c_create_date1 = &columns[8];
|
||||
assert_eq!(
|
||||
Some(Box::new(ASTNode::SQLCast {
|
||||
Some(ASTNode::SQLCast {
|
||||
expr: Box::new(ASTNode::SQLCast {
|
||||
expr: Box::new(ASTNode::SQLValue(Value::SingleQuotedString(
|
||||
"now".to_string()
|
||||
|
@ -232,7 +232,7 @@ fn parse_create_table_from_pg_dump() {
|
|||
data_type: SQLType::Text
|
||||
}),
|
||||
data_type: SQLType::Date
|
||||
})),
|
||||
}),
|
||||
c_create_date1.default
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue