Skip to content

Commit 3ec4eef

Browse files
committed
Refactoring based on comments
1 parent 3280c3d commit 3ec4eef

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/parser/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,12 +1270,14 @@ impl<'a> Parser<'a> {
12701270
}
12711271
// Handle parenthesized wildcard: (*)
12721272
Token::LParen => {
1273-
let inner_token = self.next_token();
1274-
if inner_token.token == Token::Mul && self.peek_token().token == Token::RParen {
1273+
let [maybe_mul, maybe_rparen] = self.peek_tokens_ref();
1274+
if maybe_mul.token == Token::Mul && maybe_rparen.token == Token::RParen {
1275+
let mul_token = self.next_token(); // consume Mul
12751276
self.next_token(); // consume RParen
1276-
return Ok(Expr::Wildcard(AttachedToken(inner_token)));
1277+
return Ok(Expr::Wildcard(AttachedToken(mul_token)));
12771278
}
1278-
// Not a (*), reset and fall through to parse_expr
1279+
// Not a (*), fall through to reset index and call parse_expr
1280+
self.prev_token();
12791281
}
12801282
_ => (),
12811283
};

tests/sqlparser_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17955,7 +17955,7 @@ fn test_parse_set_session_authorization() {
1795517955
}
1795617956

1795717957
#[test]
17958-
fn parse_select_distinct_parenthesized_wildcard() {
17958+
fn parse_select_parenthesized_wildcard() {
1795917959
// Test SELECT DISTINCT(*) which uses a parenthesized wildcard
1796017960
// The parentheses are syntactic sugar and get normalized to just *
1796117961
let sql = "SELECT DISTINCT (*) FROM table1";

0 commit comments

Comments
 (0)