@@ -10189,19 +10189,15 @@ fn parse_trailing_comma() {
1018910189 "Expected: column name or constraint definition, found: )" . to_string( )
1019010190 )
1019110191 ) ;
10192-
10193- let unsupported_dialects = all_dialects_where ( |d| !d. supports_trailing_commas ( ) ) ;
10194- assert_eq ! (
10195- unsupported_dialects
10196- . parse_sql_statements( "SELECT * FROM track ORDER BY milliseconds," )
10197- . unwrap_err( ) ,
10198- ParserError :: ParserError ( "Expected: an expression, found: EOF" . to_string( ) )
10199- ) ;
1020010192}
1020110193
1020210194#[ test]
1020310195fn parse_projection_trailing_comma ( ) {
10204- let trailing_commas = all_dialects_where ( |d| d. supports_projection_trailing_commas ( ) ) ;
10196+ // Some dialects allow trailing commas only in the projection
10197+ let trailing_commas = TestedDialects :: new ( vec ! [
10198+ Box :: new( SnowflakeDialect { } ) ,
10199+ Box :: new( BigQueryDialect { } ) ,
10200+ ] ) ;
1020510201
1020610202 trailing_commas. one_statement_parses_to (
1020710203 "SELECT album_id, name, FROM track" ,
@@ -10214,14 +10210,20 @@ fn parse_projection_trailing_comma() {
1021410210
1021510211 trailing_commas. verified_stmt ( "SELECT DISTINCT ON (album_id) name FROM track" ) ;
1021610212
10217- let unsupported_dialects = all_dialects_where ( |d| {
10218- !d. supports_projection_trailing_commas ( ) && !d. supports_trailing_commas ( )
10219- } ) ;
1022010213 assert_eq ! (
10221- unsupported_dialects
10222- . parse_sql_statements( "SELECT album_id, name, FROM track" )
10214+ trailing_commas
10215+ . parse_sql_statements( "SELECT * FROM track ORDER BY milliseconds, " )
1022310216 . unwrap_err( ) ,
10224- ParserError :: ParserError ( "Expected an expression, found: FROM" . to_string( ) )
10217+ ParserError :: ParserError ( "Expected: an expression, found: EOF" . to_string( ) )
10218+ ) ;
10219+
10220+ assert_eq ! (
10221+ trailing_commas
10222+ . parse_sql_statements( "CREATE TABLE employees (name text, age int,)" )
10223+ . unwrap_err( ) ,
10224+ ParserError :: ParserError (
10225+ "Expected: column name or constraint definition, found: )" . to_string( )
10226+ ) ,
1022510227 ) ;
1022610228}
1022710229
@@ -13059,33 +13061,6 @@ fn parse_overlaps() {
1305913061 verified_stmt ( "SELECT (DATE '2016-01-10', DATE '2016-02-01') OVERLAPS (DATE '2016-01-20', DATE '2016-02-10')" ) ;
1306013062}
1306113063
13062- #[ test]
13063- fn parse_column_definition_trailing_commas ( ) {
13064- let dialects = all_dialects_where ( |d| d. supports_column_definition_trailing_commas ( ) ) ;
13065-
13066- dialects. one_statement_parses_to ( "CREATE TABLE T (x INT64,)" , "CREATE TABLE T (x INT64)" ) ;
13067- dialects. one_statement_parses_to (
13068- "CREATE TABLE T (x INT64, y INT64, )" ,
13069- "CREATE TABLE T (x INT64, y INT64)" ,
13070- ) ;
13071- dialects. one_statement_parses_to (
13072- "CREATE VIEW T (x, y, ) AS SELECT 1" ,
13073- "CREATE VIEW T (x, y) AS SELECT 1" ,
13074- ) ;
13075-
13076- let unsupported_dialects = all_dialects_where ( |d| {
13077- !d. supports_projection_trailing_commas ( ) && !d. supports_trailing_commas ( )
13078- } ) ;
13079- assert_eq ! (
13080- unsupported_dialects
13081- . parse_sql_statements( "CREATE TABLE employees (name text, age int,)" )
13082- . unwrap_err( ) ,
13083- ParserError :: ParserError (
13084- "Expected: column name or constraint definition, found: )" . to_string( )
13085- ) ,
13086- ) ;
13087- }
13088-
1308913064#[ test]
1309013065fn test_trailing_commas_in_from ( ) {
1309113066 let dialects = all_dialects_where ( |d| d. supports_from_trailing_commas ( ) ) ;
0 commit comments