@@ -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 ,
@@ -1571,7 +1571,7 @@ pub enum ColumnOption {
15711571 /// `).
15721572 ForeignKey ( ForeignKeyConstraint ) ,
15731573 /// `CHECK (<expr>)`
1574- Check ( Expr ) ,
1574+ Check ( CheckConstraint ) ,
15751575 /// Dialect-specific options, such as:
15761576 /// - MySQL's `AUTO_INCREMENT` or SQLite's `AUTOINCREMENT`
15771577 /// - ...
@@ -1640,6 +1640,11 @@ pub enum ColumnOption {
16401640 Invisible ,
16411641}
16421642
1643+ impl From < CheckConstraint > for ColumnOption {
1644+ fn from ( c : CheckConstraint ) -> Self {
1645+ ColumnOption :: Check ( c)
1646+ }
1647+ }
16431648impl From < ForeignKeyConstraint > for ColumnOption {
16441649 fn from ( fk : ForeignKeyConstraint ) -> Self {
16451650 ColumnOption :: ForeignKey ( fk)
@@ -1695,7 +1700,7 @@ impl fmt::Display for ColumnOption {
16951700 }
16961701 Ok ( ( ) )
16971702 }
1698- Check ( expr ) => write ! ( f, "CHECK ({expr}) " ) ,
1703+ Check ( constraint ) => write ! ( f, "{constraint} " ) ,
16991704 DialectSpecific ( val) => write ! ( f, "{}" , display_separated( val, " " ) ) ,
17001705 CharacterSet ( n) => write ! ( f, "CHARACTER SET {n}" ) ,
17011706 Collation ( n) => write ! ( f, "COLLATE {n}" ) ,
0 commit comments