Rename SQLStatement::SQLSelect to SQLQuery

The name was confusing:
SQLStatement::SQLSelect(
  SQLQuery {
    body: SQLSetExpr::Select(SQLSelect)
  }
)

Fix the `large_enum_variant` clippy lint for `SQLStatement::SQLQuery`
`SQLStatement::SQLCreateView`, and `SQLSetExpr::Select`, while we're
changing the AST anyway
https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
This commit is contained in:
Nickolay Ponomarev 2019-04-21 02:40:02 +03:00
parent 08bbce8992
commit 50a2310173
5 changed files with 21 additions and 18 deletions

View file

@ -90,7 +90,7 @@ impl Parser {
Token::SQLWord(ref w) if w.keyword != "" => match w.keyword.as_ref() {
"SELECT" | "WITH" => {
self.prev_token();
Ok(SQLStatement::SQLSelect(self.parse_query()?))
Ok(SQLStatement::SQLQuery(Box::new(self.parse_query()?)))
}
"CREATE" => Ok(self.parse_create()?),
"DELETE" => Ok(self.parse_delete()?),
@ -655,7 +655,7 @@ impl Parser {
// Some dialects allow WITH here, followed by some keywords (e.g. MS SQL)
// or `(k1=v1, k2=v2, ...)` (Postgres)
self.expect_keyword("AS")?;
let query = self.parse_query()?;
let query = Box::new(self.parse_query()?);
// Optional `WITH [ CASCADED | LOCAL ] CHECK OPTION` is widely supported here.
Ok(SQLStatement::SQLCreateView {
name,
@ -1266,7 +1266,7 @@ impl Parser {
// We parse the expression using a Pratt parser, as in `parse_expr()`.
// Start by parsing a restricted SELECT or a `(subquery)`:
let mut expr = if self.parse_keyword("SELECT") {
SQLSetExpr::Select(self.parse_select()?)
SQLSetExpr::Select(Box::new(self.parse_select()?))
} else if self.consume_token(&Token::LParen) {
// CTEs are not allowed here, but the parser currently accepts them
let subquery = self.parse_query()?;