mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-21 13:19:46 +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
|
/// Column assignments
|
||||||
assignments: Vec<SQLAssignment>,
|
assignments: Vec<SQLAssignment>,
|
||||||
/// WHERE
|
/// WHERE
|
||||||
selection: Option<Box<ASTNode>>,
|
selection: Option<ASTNode>,
|
||||||
},
|
},
|
||||||
/// DELETE
|
/// DELETE
|
||||||
SQLDelete {
|
SQLDelete {
|
||||||
/// FROM
|
/// FROM
|
||||||
table_name: SQLObjectName,
|
table_name: SQLObjectName,
|
||||||
/// WHERE
|
/// WHERE
|
||||||
selection: Option<Box<ASTNode>>,
|
selection: Option<ASTNode>,
|
||||||
},
|
},
|
||||||
/// CREATE TABLE
|
/// CREATE TABLE
|
||||||
SQLCreateTable {
|
SQLCreateTable {
|
||||||
|
@ -264,7 +264,7 @@ impl ToString for SQLStatement {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let Some(selection) = selection {
|
if let Some(selection) = selection {
|
||||||
s += &format!(" WHERE {}", selection.as_ref().to_string());
|
s += &format!(" WHERE {}", selection.to_string());
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ impl ToString for SQLStatement {
|
||||||
} => {
|
} => {
|
||||||
let mut s = format!("DELETE FROM {}", table_name.to_string());
|
let mut s = format!("DELETE FROM {}", table_name.to_string());
|
||||||
if let Some(selection) = selection {
|
if let Some(selection) = selection {
|
||||||
s += &format!(" WHERE {}", selection.as_ref().to_string());
|
s += &format!(" WHERE {}", selection.to_string());
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
@ -308,12 +308,12 @@ impl ToString for SQLObjectName {
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct SQLAssignment {
|
pub struct SQLAssignment {
|
||||||
id: SQLIdent,
|
id: SQLIdent,
|
||||||
value: Box<ASTNode>,
|
value: ASTNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for SQLAssignment {
|
impl ToString for SQLAssignment {
|
||||||
fn to_string(&self) -> String {
|
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 data_type: SQLType,
|
||||||
pub is_primary: bool,
|
pub is_primary: bool,
|
||||||
pub is_unique: bool,
|
pub is_unique: bool,
|
||||||
pub default: Option<Box<ASTNode>>,
|
pub default: Option<ASTNode>,
|
||||||
pub allow_null: bool,
|
pub allow_null: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ impl ToString for SQLColumnDef {
|
||||||
s += " UNIQUE";
|
s += " UNIQUE";
|
||||||
}
|
}
|
||||||
if let Some(ref default) = self.default {
|
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 {
|
if !self.allow_null {
|
||||||
s += " NOT NULL";
|
s += " NOT NULL";
|
||||||
|
|
|
@ -553,7 +553,7 @@ impl Parser {
|
||||||
let is_unique = self.parse_keyword("UNIQUE");
|
let is_unique = self.parse_keyword("UNIQUE");
|
||||||
let default = if self.parse_keyword("DEFAULT") {
|
let default = if self.parse_keyword("DEFAULT") {
|
||||||
let expr = self.parse_default_expr(0)?;
|
let expr = self.parse_default_expr(0)?;
|
||||||
Some(Box::new(expr))
|
Some(expr)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -1104,7 +1104,7 @@ impl Parser {
|
||||||
self.expect_keyword("FROM")?;
|
self.expect_keyword("FROM")?;
|
||||||
let table_name = self.parse_object_name()?;
|
let table_name = self.parse_object_name()?;
|
||||||
let selection = if self.parse_keyword("WHERE") {
|
let selection = if self.parse_keyword("WHERE") {
|
||||||
Some(Box::new(self.parse_expr()?))
|
Some(self.parse_expr()?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn parse_where_delete_statement() {
|
||||||
op: Eq,
|
op: Eq,
|
||||||
right: Box::new(SQLValue(Value::Long(5))),
|
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];
|
let c_create_date1 = &columns[8];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Some(Box::new(ASTNode::SQLCast {
|
Some(ASTNode::SQLCast {
|
||||||
expr: Box::new(ASTNode::SQLCast {
|
expr: Box::new(ASTNode::SQLCast {
|
||||||
expr: Box::new(ASTNode::SQLValue(Value::SingleQuotedString(
|
expr: Box::new(ASTNode::SQLValue(Value::SingleQuotedString(
|
||||||
"now".to_string()
|
"now".to_string()
|
||||||
|
@ -232,7 +232,7 @@ fn parse_create_table_from_pg_dump() {
|
||||||
data_type: SQLType::Text
|
data_type: SQLType::Text
|
||||||
}),
|
}),
|
||||||
data_type: SQLType::Date
|
data_type: SQLType::Date
|
||||||
})),
|
}),
|
||||||
c_create_date1.default
|
c_create_date1.default
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue