@@ -30,7 +30,7 @@ use sqlparser_derive::{Visit, VisitMut};
30
30
31
31
use crate :: ast:: value:: escape_single_quote_string;
32
32
use crate :: ast:: {
33
- display_comma_separated, display_separated, table_constraints:: TableConstraint , ArgMode ,
33
+ display_comma_separated, display_separated, table_constraints:: { CheckConstraint , TableConstraint } , ArgMode ,
34
34
CommentDef , ConditionalStatements , CreateFunctionBody , CreateFunctionUsing ,
35
35
CreateTableLikeKind , CreateTableOptions , DataType , Expr , FileFormat , FunctionBehavior ,
36
36
FunctionCalledOnNull , FunctionDeterminismSpecifier , FunctionParallel , HiveDistributionStyle ,
@@ -1573,7 +1573,7 @@ pub enum ColumnOption {
1573
1573
characteristics : Option < ConstraintCharacteristics > ,
1574
1574
} ,
1575
1575
/// `CHECK (<expr>)`
1576
- Check ( Expr ) ,
1576
+ Check ( CheckConstraint ) ,
1577
1577
/// Dialect-specific options, such as:
1578
1578
/// - MySQL's `AUTO_INCREMENT` or SQLite's `AUTOINCREMENT`
1579
1579
/// - ...
@@ -1642,6 +1642,12 @@ pub enum ColumnOption {
1642
1642
Invisible ,
1643
1643
}
1644
1644
1645
+ impl From < CheckConstraint > for ColumnOption {
1646
+ fn from ( c : CheckConstraint ) -> Self {
1647
+ ColumnOption :: Check ( c)
1648
+ }
1649
+ }
1650
+
1645
1651
impl fmt:: Display for ColumnOption {
1646
1652
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1647
1653
use ColumnOption :: * ;
@@ -1690,7 +1696,7 @@ impl fmt::Display for ColumnOption {
1690
1696
}
1691
1697
Ok ( ( ) )
1692
1698
}
1693
- Check ( expr ) => write ! ( f, "CHECK ({expr}) " ) ,
1699
+ Check ( constraint ) => write ! ( f, "{constraint} " ) ,
1694
1700
DialectSpecific ( val) => write ! ( f, "{}" , display_separated( val, " " ) ) ,
1695
1701
CharacterSet ( n) => write ! ( f, "CHARACTER SET {n}" ) ,
1696
1702
Collation ( n) => write ! ( f, "COLLATE {n}" ) ,
0 commit comments