@@ -31,7 +31,7 @@ use sqlparser_derive::{Visit, VisitMut};
3131use crate :: ast:: value:: escape_single_quote_string;
3232use crate :: ast:: {
3333 display_comma_separated, display_separated,
34- table_constraints:: { ForeignKeyConstraint , TableConstraint } ,
34+ table_constraints:: { CheckConstraint , ForeignKeyConstraint , TableConstraint } ,
3535 ArgMode , AttachedToken , CommentDef , ConditionalStatements , CreateFunctionBody ,
3636 CreateFunctionUsing , CreateTableLikeKind , CreateTableOptions , CreateViewParams , DataType , Expr ,
3737 FileFormat , FunctionBehavior , FunctionCalledOnNull , FunctionDesc , FunctionDeterminismSpecifier ,
@@ -1569,7 +1569,7 @@ pub enum ColumnOption {
15691569 /// `).
15701570 ForeignKey ( ForeignKeyConstraint ) ,
15711571 /// `CHECK (<expr>)`
1572- Check ( Expr ) ,
1572+ Check ( CheckConstraint ) ,
15731573 /// Dialect-specific options, such as:
15741574 /// - MySQL's `AUTO_INCREMENT` or SQLite's `AUTOINCREMENT`
15751575 /// - ...
@@ -1638,6 +1638,11 @@ pub enum ColumnOption {
16381638 Invisible ,
16391639}
16401640
1641+ impl From < CheckConstraint > for ColumnOption {
1642+ fn from ( c : CheckConstraint ) -> Self {
1643+ ColumnOption :: Check ( c)
1644+ }
1645+ }
16411646impl From < ForeignKeyConstraint > for ColumnOption {
16421647 fn from ( fk : ForeignKeyConstraint ) -> Self {
16431648 ColumnOption :: ForeignKey ( fk)
@@ -1693,7 +1698,7 @@ impl fmt::Display for ColumnOption {
16931698 }
16941699 Ok ( ( ) )
16951700 }
1696- Check ( expr ) => write ! ( f, "CHECK ({expr}) " ) ,
1701+ Check ( constraint ) => write ! ( f, "{constraint} " ) ,
16971702 DialectSpecific ( val) => write ! ( f, "{}" , display_separated( val, " " ) ) ,
16981703 CharacterSet ( n) => write ! ( f, "CHARACTER SET {n}" ) ,
16991704 Collation ( n) => write ! ( f, "COLLATE {n}" ) ,
0 commit comments