Skip to content

Commit 5cbf1e7

Browse files
authored
Fix new clippy errors (#412)
1 parent fbc1d96 commit 5cbf1e7

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/ast/ddl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl fmt::Display for AlterTableOperation {
9292
),
9393
AlterTableOperation::AddConstraint(c) => write!(f, "ADD {}", c),
9494
AlterTableOperation::AddColumn { column_def } => {
95-
write!(f, "ADD COLUMN {}", column_def.to_string())
95+
write!(f, "ADD COLUMN {}", column_def)
9696
}
9797
AlterTableOperation::AlterColumn { column_name, op } => {
9898
write!(f, "ALTER COLUMN {} {}", column_name, op)

src/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ impl fmt::Display for Privileges {
15481548
)
15491549
}
15501550
Privileges::Actions(actions) => {
1551-
write!(f, "{}", display_comma_separated(actions).to_string())
1551+
write!(f, "{}", display_comma_separated(actions))
15521552
}
15531553
}
15541554
}

src/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,16 +2649,16 @@ impl<'a> Parser<'a> {
26492649
};
26502650

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

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

2660-
if is_l_parent {
2661-
self.consume_token(&Token::RParen);
2660+
if is_l_paren && !self.consume_token(&Token::RParen) {
2661+
return self.expected(")", self.peek_token());
26622662
}
26632663

26642664
// Note that for keywords to be properly handled here, they need to be

tests/sqlparser_common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,15 @@ fn parse_select_distinct_two_fields() {
343343
);
344344
}
345345

346+
#[test]
347+
fn parse_select_distinct_missing_paren() {
348+
let result = parse_sql_statements("SELECT DISTINCT (name, id FROM customer");
349+
assert_eq!(
350+
ParserError::ParserError("Expected ), found: FROM".to_string()),
351+
result.unwrap_err(),
352+
);
353+
}
354+
346355
#[test]
347356
fn parse_select_all() {
348357
one_statement_parses_to("SELECT ALL name FROM customer", "SELECT name FROM customer");

0 commit comments

Comments
 (0)