@@ -33,7 +33,9 @@ use crate::ast::table_constraints::TableConstraint;
3333use crate :: ast:: value:: escape_single_quote_string;
3434use crate :: ast:: {
3535 display_comma_separated, display_separated,
36- table_constraints:: { ForeignKeyConstraint , PrimaryKeyConstraint , UniqueConstraint } ,
36+ table_constraints:: {
37+ CheckConstraint , ForeignKeyConstraint , PrimaryKeyConstraint , UniqueConstraint ,
38+ } ,
3739 ArgMode , CommentDef , ConditionalStatements , CreateFunctionBody , CreateFunctionUsing ,
3840 CreateTableLikeKind , CreateTableOptions , DataType , Expr , FileFormat , FunctionBehavior ,
3941 FunctionCalledOnNull , FunctionDeterminismSpecifier , FunctionParallel , HiveDistributionStyle ,
@@ -1585,7 +1587,7 @@ pub enum ColumnOption {
15851587 /// `).
15861588 ForeignKey ( ForeignKeyConstraint ) ,
15871589 /// `CHECK (<expr>)`
1588- Check ( Expr ) ,
1590+ Check ( CheckConstraint ) ,
15891591 /// Dialect-specific options, such as:
15901592 /// - MySQL's `AUTO_INCREMENT` or SQLite's `AUTOINCREMENT`
15911593 /// - ...
@@ -1670,6 +1672,11 @@ impl From<PrimaryKeyConstraint> for ColumnOption {
16701672 ColumnOption :: PrimaryKey ( c)
16711673 }
16721674}
1675+ impl From < CheckConstraint > for ColumnOption {
1676+ fn from ( c : CheckConstraint ) -> Self {
1677+ ColumnOption :: Check ( c)
1678+ }
1679+ }
16731680
16741681impl fmt:: Display for ColumnOption {
16751682 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
@@ -1724,7 +1731,7 @@ impl fmt::Display for ColumnOption {
17241731 }
17251732 Ok ( ( ) )
17261733 }
1727- Check ( expr ) => write ! ( f, "CHECK ({expr}) " ) ,
1734+ Check ( constraint ) => write ! ( f, "{constraint} " ) ,
17281735 DialectSpecific ( val) => write ! ( f, "{}" , display_separated( val, " " ) ) ,
17291736 CharacterSet ( n) => write ! ( f, "CHARACTER SET {n}" ) ,
17301737 Collation ( n) => write ! ( f, "COLLATE {n}" ) ,
0 commit comments