1616// under the License.
1717
1818#[ cfg( not( feature = "std" ) ) ]
19- use alloc:: { format, string:: String , vec:: Vec } ;
19+ use alloc:: { boxed :: Box , format, string:: String , vec:: Vec } ;
2020
2121#[ cfg( feature = "serde" ) ]
2222use serde:: { Deserialize , Serialize } ;
@@ -25,7 +25,8 @@ use serde::{Deserialize, Serialize};
2525use sqlparser_derive:: { Visit , VisitMut } ;
2626
2727use crate :: ast:: {
28- CatalogSyncNamespaceMode , ContactEntry , ObjectName , Statement , StorageSerializationPolicy , Tag ,
28+ CatalogSyncNamespaceMode , ContactEntry , CreateDatabase , ObjectName , Statement ,
29+ StorageSerializationPolicy , Tag ,
2930} ;
3031use crate :: parser:: ParserError ;
3132
@@ -278,7 +279,7 @@ impl CreateDatabaseBuilder {
278279
279280 /// Build the `CREATE DATABASE` statement.
280281 pub fn build ( self ) -> Statement {
281- Statement :: CreateDatabase {
282+ Statement :: CreateDatabase ( Box :: new ( CreateDatabase {
282283 db_name : self . db_name ,
283284 if_not_exists : self . if_not_exists ,
284285 managed_location : self . managed_location ,
@@ -301,7 +302,7 @@ impl CreateDatabaseBuilder {
301302 catalog_sync_namespace_flatten_delimiter : self . catalog_sync_namespace_flatten_delimiter ,
302303 with_tags : self . with_tags ,
303304 with_contacts : self . with_contacts ,
304- }
305+ } ) )
305306 }
306307}
307308
@@ -310,53 +311,56 @@ impl TryFrom<Statement> for CreateDatabaseBuilder {
310311
311312 fn try_from ( stmt : Statement ) -> Result < Self , Self :: Error > {
312313 match stmt {
313- Statement :: CreateDatabase {
314- db_name,
315- if_not_exists,
316- location,
317- managed_location,
318- or_replace,
319- transient,
320- clone,
321- data_retention_time_in_days,
322- max_data_extension_time_in_days,
323- external_volume,
324- catalog,
325- replace_invalid_characters,
326- default_ddl_collation,
327- storage_serialization_policy,
328- comment,
329- default_charset,
330- default_collation,
331- catalog_sync,
332- catalog_sync_namespace_mode,
333- catalog_sync_namespace_flatten_delimiter,
334- with_tags,
335- with_contacts,
336- } => Ok ( Self {
337- db_name,
338- if_not_exists,
339- location,
340- managed_location,
341- or_replace,
342- transient,
343- clone,
344- data_retention_time_in_days,
345- max_data_extension_time_in_days,
346- external_volume,
347- catalog,
348- replace_invalid_characters,
349- default_ddl_collation,
350- storage_serialization_policy,
351- comment,
352- default_charset,
353- default_collation,
354- catalog_sync,
355- catalog_sync_namespace_mode,
356- catalog_sync_namespace_flatten_delimiter,
357- with_tags,
358- with_contacts,
359- } ) ,
314+ Statement :: CreateDatabase ( create_database) => {
315+ let CreateDatabase {
316+ db_name,
317+ if_not_exists,
318+ location,
319+ managed_location,
320+ or_replace,
321+ transient,
322+ clone,
323+ data_retention_time_in_days,
324+ max_data_extension_time_in_days,
325+ external_volume,
326+ catalog,
327+ replace_invalid_characters,
328+ default_ddl_collation,
329+ storage_serialization_policy,
330+ comment,
331+ default_charset,
332+ default_collation,
333+ catalog_sync,
334+ catalog_sync_namespace_mode,
335+ catalog_sync_namespace_flatten_delimiter,
336+ with_tags,
337+ with_contacts,
338+ } = * create_database;
339+ Ok ( Self {
340+ db_name,
341+ if_not_exists,
342+ location,
343+ managed_location,
344+ or_replace,
345+ transient,
346+ clone,
347+ data_retention_time_in_days,
348+ max_data_extension_time_in_days,
349+ external_volume,
350+ catalog,
351+ replace_invalid_characters,
352+ default_ddl_collation,
353+ storage_serialization_policy,
354+ comment,
355+ default_charset,
356+ default_collation,
357+ catalog_sync,
358+ catalog_sync_namespace_mode,
359+ catalog_sync_namespace_flatten_delimiter,
360+ with_tags,
361+ with_contacts,
362+ } )
363+ }
360364 _ => Err ( ParserError :: ParserError ( format ! (
361365 "Expected create database statement, but received: {stmt}"
362366 ) ) ) ,
@@ -367,7 +371,7 @@ impl TryFrom<Statement> for CreateDatabaseBuilder {
367371#[ cfg( test) ]
368372mod tests {
369373 use crate :: ast:: helpers:: stmt_create_database:: CreateDatabaseBuilder ;
370- use crate :: ast:: { Ident , ObjectName , Statement } ;
374+ use crate :: ast:: { Commit , Ident , ObjectName , Statement } ;
371375 use crate :: parser:: ParserError ;
372376
373377 #[ test]
@@ -381,11 +385,11 @@ mod tests {
381385
382386 #[ test]
383387 pub fn test_from_invalid_statement ( ) {
384- let stmt = Statement :: Commit {
388+ let stmt = Statement :: Commit ( Box :: new ( Commit {
385389 chain : false ,
386390 end : false ,
387391 modifier : None ,
388- } ;
392+ } ) ) ;
389393
390394 assert_eq ! (
391395 CreateDatabaseBuilder :: try_from( stmt) . unwrap_err( ) ,
0 commit comments