File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1354,7 +1354,11 @@ impl Parser {
1354
1354
/// Parse a restricted `SELECT` statement (no CTEs / `UNION` / `ORDER BY`),
1355
1355
/// assuming the initial `SELECT` was already consumed
1356
1356
pub fn parse_select ( & mut self ) -> Result < SQLSelect , ParserError > {
1357
+ let all = self . parse_keyword ( "ALL" ) ;
1357
1358
let distinct = self . parse_keyword ( "DISTINCT" ) ;
1359
+ if all && distinct {
1360
+ return parser_err ! ( "Cannot specify both ALL and DISTINCT in SELECT" ) ;
1361
+ }
1358
1362
let projection = self . parse_select_list ( ) ?;
1359
1363
1360
1364
let ( relation, joins) = if self . parse_keyword ( "FROM" ) {
Original file line number Diff line number Diff line change @@ -135,6 +135,20 @@ fn parse_select_distinct() {
135
135
) ;
136
136
}
137
137
138
+ #[ test]
139
+ fn parse_select_all ( ) {
140
+ one_statement_parses_to ( "SELECT ALL name FROM customer" , "SELECT name FROM customer" ) ;
141
+ }
142
+
143
+ #[ test]
144
+ fn parse_select_all_distinct ( ) {
145
+ let result = parse_sql_statements ( "SELECT ALL DISTINCT name FROM customer" ) ;
146
+ assert_eq ! (
147
+ ParserError :: ParserError ( "Cannot specify both ALL and DISTINCT in SELECT" . to_string( ) ) ,
148
+ result. unwrap_err( ) ,
149
+ ) ;
150
+ }
151
+
138
152
#[ test]
139
153
fn parse_select_wildcard ( ) {
140
154
let sql = "SELECT * FROM foo" ;
You can’t perform that action at this time.
0 commit comments