1414//! (commonly referred to as Data Definition Language, or DDL)
1515
1616#[ cfg( not( feature = "std" ) ) ]
17- use alloc:: { boxed:: Box , string:: ToString , vec:: Vec } ;
17+ use alloc:: { boxed:: Box , string:: String , string :: ToString , vec:: Vec } ;
1818use core:: fmt;
1919
2020#[ cfg( feature = "serde" ) ]
2121use serde:: { Deserialize , Serialize } ;
2222
23+ use crate :: ast:: value:: escape_single_quote_string;
2324use crate :: ast:: { display_comma_separated, display_separated, DataType , Expr , Ident , ObjectName } ;
2425use crate :: tokenizer:: Token ;
2526
@@ -338,7 +339,9 @@ pub enum ColumnOption {
338339 /// `DEFAULT <restricted-expr>`
339340 Default ( Expr ) ,
340341 /// `{ PRIMARY KEY | UNIQUE }`
341- Unique { is_primary : bool } ,
342+ Unique {
343+ is_primary : bool ,
344+ } ,
342345 /// A referential integrity constraint (`[FOREIGN KEY REFERENCES
343346 /// <foreign_table> (<referred_columns>)
344347 /// { [ON DELETE <referential_action>] [ON UPDATE <referential_action>] |
@@ -356,6 +359,8 @@ pub enum ColumnOption {
356359 /// - MySQL's `AUTO_INCREMENT` or SQLite's `AUTOINCREMENT`
357360 /// - ...
358361 DialectSpecific ( Vec < Token > ) ,
362+ CharacterSet ( ObjectName ) ,
363+ Comment ( String ) ,
359364}
360365
361366impl fmt:: Display for ColumnOption {
@@ -388,6 +393,8 @@ impl fmt::Display for ColumnOption {
388393 }
389394 Check ( expr) => write ! ( f, "CHECK ({})" , expr) ,
390395 DialectSpecific ( val) => write ! ( f, "{}" , display_separated( val, " " ) ) ,
396+ CharacterSet ( n) => write ! ( f, "CHARACTER SET {}" , n) ,
397+ Comment ( v) => write ! ( f, "COMMENT '{}'" , escape_single_quote_string( v) ) ,
391398 }
392399 }
393400}
0 commit comments