WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c2a1d3e

Browse files
committed
Refactoring based on comments
1 parent b9ca161 commit c2a1d3e

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
@@ -1224,12 +1224,14 @@ impl<'a> Parser<'a> {
12241224
}
12251225
// Handle parenthesized wildcard: (*)
12261226
Token::LParen => {
1227-
let inner_token = self.next_token();
1228-
if inner_token.token == Token::Mul && self.peek_token().token == Token::RParen {
1227+
let [maybe_mul, maybe_rparen] = self.peek_tokens_ref();
1228+
if maybe_mul.token == Token::Mul && maybe_rparen.token == Token::RParen {
1229+
let mul_token = self.next_token(); // consume Mul
12291230
self.next_token(); // consume RParen
1230-
return Ok(Expr::Wildcard(AttachedToken(inner_token)));
1231+
return Ok(Expr::Wildcard(AttachedToken(mul_token)));
12311232
}
1232-
// Not a (*), reset and fall through to parse_expr
1233+
// Not a (*), fall through to reset index and call parse_expr
1234+
self.prev_token();
12331235
}
12341236
_ => (),
12351237
};

tests/sqlparser_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17907,7 +17907,7 @@ fn test_parse_set_session_authorization() {
1790717907
}
1790817908

1790917909
#[test]
17910-
fn parse_select_distinct_parenthesized_wildcard() {
17910+
fn parse_select_parenthesized_wildcard() {
1791117911
// Test SELECT DISTINCT(*) which uses a parenthesized wildcard
1791217912
// The parentheses are syntactic sugar and get normalized to just *
1791317913
let sql = "SELECT DISTINCT (*) FROM table1";

0 commit comments

Comments
 (0)