Skip to content

Fix new clippy errors #412

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

Merged
merged 1 commit into from
Feb 5, 2022
Merged
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
2 changes: 1 addition & 1 deletion src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl fmt::Display for AlterTableOperation {
),
AlterTableOperation::AddConstraint(c) => write!(f, "ADD {}", c),
AlterTableOperation::AddColumn { column_def } => {
write!(f, "ADD COLUMN {}", column_def.to_string())
write!(f, "ADD COLUMN {}", column_def)
}
AlterTableOperation::AlterColumn { column_name, op } => {
write!(f, "ALTER COLUMN {} {}", column_name, op)
Expand Down
2 changes: 1 addition & 1 deletion src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ impl fmt::Display for Privileges {
)
}
Privileges::Actions(actions) => {
write!(f, "{}", display_comma_separated(actions).to_string())
write!(f, "{}", display_comma_separated(actions))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2649,16 +2649,16 @@ impl<'a> Parser<'a> {
};

// Not Sure if Top should be cheked here as well. Trino doesn't support TOP.
let is_l_parent = if distinct {
let is_l_paren = if distinct {
self.consume_token(&Token::LParen)
} else {
false
};

let projection = self.parse_comma_separated(Parser::parse_select_item)?;

if is_l_parent {
self.consume_token(&Token::RParen);
if is_l_paren && !self.consume_token(&Token::RParen) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy was complaining (rightly) that the return value from consume_token was not used

return self.expected(")", self.peek_token());
}

// Note that for keywords to be properly handled here, they need to be
Expand Down
9 changes: 9 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,15 @@ fn parse_select_distinct_two_fields() {
);
}

#[test]
fn parse_select_distinct_missing_paren() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test for new code

let result = parse_sql_statements("SELECT DISTINCT (name, id FROM customer");
assert_eq!(
ParserError::ParserError("Expected ), found: FROM".to_string()),
result.unwrap_err(),
);
}

#[test]
fn parse_select_all() {
one_statement_parses_to("SELECT ALL name FROM customer", "SELECT name FROM customer");
Expand Down