Skip to content

Remove unnecessary Box #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ pub enum Statement {
repair: bool,
partition_action: Option<AddDropSync>,
},
/// SELECT
Query(Box<Query>),
/// SELECT, VALUES
Query(Query),
/// INSERT
Insert {
/// Only for Sqlite
Expand Down
2 changes: 1 addition & 1 deletion src/ast/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub enum SetExpr {
Select(Box<Select>),
/// Parenthesized SELECT subquery, which may include more set operations
/// in its body and an optional ORDER BY / LIMIT.
Query(Box<Query>),
Query(Query),
/// UNION/EXCEPT/INTERSECT of two queries
SetOperation {
op: SetOperator,
Expand Down
6 changes: 3 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'a> Parser<'a> {
Keyword::ANALYZE => Ok(self.parse_analyze()?),
Keyword::SELECT | Keyword::WITH | Keyword::VALUES => {
self.prev_token();
Ok(Statement::Query(Box::new(self.parse_query()?)))
Ok(Statement::Query(self.parse_query()?))
}
Keyword::TRUNCATE => Ok(self.parse_truncate()?),
Keyword::MSCK => Ok(self.parse_msck()?),
Expand Down Expand Up @@ -205,7 +205,7 @@ impl<'a> Parser<'a> {
},
Token::LParen => {
self.prev_token();
Ok(Statement::Query(Box::new(self.parse_query()?)))
Ok(Statement::Query(self.parse_query()?))
}
unexpected => self.expected("an SQL statement", unexpected),
}
Expand Down Expand Up @@ -3429,7 +3429,7 @@ impl<'a> Parser<'a> {
// CTEs are not allowed here, but the parser currently accepts them
let subquery = self.parse_query()?;
self.expect_token(&Token::RParen)?;
SetExpr::Query(Box::new(subquery))
SetExpr::Query(subquery)
} else if self.parse_keyword(Keyword::VALUES) {
SetExpr::Values(self.parse_values()?)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl TestedDialects {
/// after a serialization round-trip.
pub fn verified_query(&self, sql: &str) -> Query {
match self.verified_stmt(sql) {
Statement::Query(query) => *query,
Statement::Query(query) => query,
_ => panic!("Expected Query"),
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/sqlparser_mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn parse_quote_identifiers_2() {
let sql = "SELECT `quoted `` identifier`";
assert_eq!(
mysql().verified_stmt(sql),
Statement::Query(Box::new(Query {
Statement::Query(Query {
with: None,
body: Box::new(SetExpr::Select(Box::new(Select {
distinct: false,
Expand All @@ -337,7 +337,7 @@ fn parse_quote_identifiers_2() {
offset: None,
fetch: None,
lock: None,
}))
})
);
}

Expand All @@ -346,7 +346,7 @@ fn parse_quote_identifiers_3() {
let sql = "SELECT ```quoted identifier```";
assert_eq!(
mysql().verified_stmt(sql),
Statement::Query(Box::new(Query {
Statement::Query(Query {
with: None,
body: Box::new(SetExpr::Select(Box::new(Select {
distinct: false,
Expand All @@ -371,7 +371,7 @@ fn parse_quote_identifiers_3() {
offset: None,
fetch: None,
lock: None,
}))
})
);
}

Expand Down Expand Up @@ -766,7 +766,7 @@ fn parse_substring_in_select() {
) {
Statement::Query(query) => {
assert_eq!(
Box::new(Query {
Query {
with: None,
body: Box::new(SetExpr::Select(Box::new(Select {
distinct: true,
Expand Down Expand Up @@ -812,7 +812,7 @@ fn parse_substring_in_select() {
offset: None,
fetch: None,
lock: None,
}),
},
query
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,9 +1068,9 @@ fn parse_prepare() {
};
assert_eq!(
sub_stmt,
Box::new(Statement::Query(Box::new(pg_and_generic().verified_query(
Box::new(Statement::Query(pg_and_generic().verified_query(
"SELECT * FROM customers WHERE customers.id = a1"
))))
)))
);
}

Expand Down