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
File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -1222,6 +1222,15 @@ impl<'a> Parser<'a> {
12221222 Token::Mul => {
12231223 return Ok(Expr::Wildcard(AttachedToken(next_token)));
12241224 }
1225+ // Handle parenthesized wildcard: (*)
1226+ Token::LParen => {
1227+ let inner_token = self.next_token();
1228+ if inner_token.token == Token::Mul && self.peek_token().token == Token::RParen {
1229+ self.next_token(); // consume RParen
1230+ return Ok(Expr::Wildcard(AttachedToken(inner_token)));
1231+ }
1232+ // Not a (*), reset and fall through to parse_expr
1233+ }
12251234 _ => (),
12261235 };
12271236
Original file line number Diff line number Diff line change @@ -17905,3 +17905,22 @@ fn test_parse_set_session_authorization() {
1790517905 }))
1790617906 );
1790717907}
17908+
17909+ #[test]
17910+ fn parse_select_distinct_parenthesized_wildcard() {
17911+ // Test SELECT DISTINCT(*) which uses a parenthesized wildcard
17912+ // The parentheses are syntactic sugar and get normalized to just *
17913+ let sql = "SELECT DISTINCT (*) FROM table1";
17914+ let canonical = "SELECT DISTINCT * FROM table1";
17915+ let select = all_dialects().verified_only_select_with_canonical(sql, canonical);
17916+ assert_eq!(select.distinct, Some(Distinct::Distinct));
17917+ assert_eq!(select.projection.len(), 1);
17918+ assert!(matches!(select.projection[0], SelectItem::Wildcard(_)));
17919+
17920+ // Also test without spaces: SELECT DISTINCT(*)
17921+ let sql_no_spaces = "SELECT DISTINCT(*) FROM table1";
17922+ let select2 = all_dialects().verified_only_select_with_canonical(sql_no_spaces, canonical);
17923+ assert_eq!(select2.distinct, Some(Distinct::Distinct));
17924+ assert_eq!(select2.projection.len(), 1);
17925+ assert!(matches!(select2.projection[0], SelectItem::Wildcard(_)));
17926+ }
You can’t perform that action at this time.
0 commit comments