@@ -1896,13 +1896,32 @@ impl<'a> Parser<'a> {
18961896
18971897    pub  fn  parse_create_schema ( & mut  self )  -> Result < Statement ,  ParserError >  { 
18981898        let  if_not_exists = self . parse_keywords ( & [ Keyword :: IF ,  Keyword :: NOT ,  Keyword :: EXISTS ] ) ; 
1899-         let  schema_name = self . parse_object_name ( ) ?; 
1899+ 
1900+         let  schema_name = self . parse_schema_name ( ) ?; 
1901+ 
19001902        Ok ( Statement :: CreateSchema  { 
19011903            schema_name, 
19021904            if_not_exists, 
19031905        } ) 
19041906    } 
19051907
1908+     fn  parse_schema_name ( & mut  self )  -> Result < SchemaName ,  ParserError >  { 
1909+         if  self . parse_keyword ( Keyword :: AUTHORIZATION )  { 
1910+             Ok ( SchemaName :: UnnamedAuthorization ( self . parse_identifier ( ) ?) ) 
1911+         }  else  { 
1912+             let  name = self . parse_object_name ( ) ?; 
1913+ 
1914+             if  self . parse_keyword ( Keyword :: AUTHORIZATION )  { 
1915+                 Ok ( SchemaName :: NamedAuthorization ( 
1916+                     name, 
1917+                     self . parse_identifier ( ) ?, 
1918+                 ) ) 
1919+             }  else  { 
1920+                 Ok ( SchemaName :: Simple ( name) ) 
1921+             } 
1922+         } 
1923+     } 
1924+ 
19061925    pub  fn  parse_create_database ( & mut  self )  -> Result < Statement ,  ParserError >  { 
19071926        let  ine = self . parse_keywords ( & [ Keyword :: IF ,  Keyword :: NOT ,  Keyword :: EXISTS ] ) ; 
19081927        let  db_name = self . parse_object_name ( ) ?; 
@@ -5345,4 +5364,37 @@ mod tests {
53455364            } ) ; 
53465365        } 
53475366    } 
5367+ 
5368+     #[ test]  
5369+     fn  test_parse_schema_name ( )  { 
5370+         // The expected name should be identical as the input name, that's why I don't receive both 
5371+         macro_rules!  test_parse_schema_name { 
5372+             ( $input: expr,  $expected_name: expr $( , ) ?)  => { { 
5373+                 all_dialects( ) . run_parser_method( & * $input,  |parser| { 
5374+                     let  schema_name = parser. parse_schema_name( ) . unwrap( ) ; 
5375+                     // Validate that the structure is the same as expected 
5376+                     assert_eq!( schema_name,  $expected_name) ; 
5377+                     // Validate that the input and the expected structure serialization are the same 
5378+                     assert_eq!( schema_name. to_string( ) ,  $input. to_string( ) ) ; 
5379+                 } ) ; 
5380+             } } ; 
5381+         } 
5382+ 
5383+         let  dummy_name = ObjectName ( vec ! [ Ident :: new( "dummy_name" ) ] ) ; 
5384+         let  dummy_authorization = Ident :: new ( "dummy_authorization" ) ; 
5385+ 
5386+         test_parse_schema_name ! ( 
5387+             format!( "{dummy_name}" ) , 
5388+             SchemaName :: Simple ( dummy_name. clone( ) ) 
5389+         ) ; 
5390+ 
5391+         test_parse_schema_name ! ( 
5392+             format!( "AUTHORIZATION {dummy_authorization}" ) , 
5393+             SchemaName :: UnnamedAuthorization ( dummy_authorization. clone( ) ) , 
5394+         ) ; 
5395+         test_parse_schema_name ! ( 
5396+             format!( "{dummy_name} AUTHORIZATION {dummy_authorization}" ) , 
5397+             SchemaName :: NamedAuthorization ( dummy_name. clone( ) ,  dummy_authorization. clone( ) ) , 
5398+         ) ; 
5399+     } 
53485400} 
0 commit comments