@@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize};
29
29
#[ cfg( feature = "visitor" ) ]
30
30
use sqlparser_derive:: { Visit , VisitMut } ;
31
31
32
- use crate :: display_utils:: { indented_list, Indent , SpaceOrNewline } ;
32
+ use crate :: display_utils:: { indented_list, DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
33
33
34
34
pub use super :: ddl:: { ColumnDef , TableConstraint } ;
35
35
@@ -267,14 +267,19 @@ impl Display for CreateTable {
267
267
write ! ( f, " ON CLUSTER {}" , on_cluster) ?;
268
268
}
269
269
if !self . columns . is_empty ( ) || !self . constraints . is_empty ( ) {
270
- write ! ( f, " ({}" , display_comma_separated( & self . columns) ) ?;
270
+ f. write_str ( " (" ) ?;
271
+ NewLine . fmt ( f) ?;
272
+ Indent ( DisplayCommaSeparated ( & self . columns ) ) . fmt ( f) ?;
271
273
if !self . columns . is_empty ( ) && !self . constraints . is_empty ( ) {
272
- write ! ( f, ", " ) ?;
274
+ f. write_str ( "," ) ?;
275
+ SpaceOrNewline . fmt ( f) ?;
273
276
}
274
- write ! ( f, "{})" , display_comma_separated( & self . constraints) ) ?;
277
+ Indent ( DisplayCommaSeparated ( & self . constraints ) ) . fmt ( f) ?;
278
+ NewLine . fmt ( f) ?;
279
+ f. write_str ( ")" ) ?;
275
280
} else if self . query . is_none ( ) && self . like . is_none ( ) && self . clone . is_none ( ) {
276
281
// PostgreSQL allows `CREATE TABLE t ();`, but requires empty parens
277
- write ! ( f , " ()" ) ?;
282
+ f . write_str ( " ()" ) ?;
278
283
}
279
284
280
285
// Hive table comment should be after column definitions, please refer to:
0 commit comments