@@ -78,7 +78,7 @@ pub enum TableConstraint {
7878 /// [ON UPDATE <referential_action>] [ON DELETE <referential_action>]
7979 /// }`).
8080 ForeignKey ( ForeignKeyConstraint ) ,
81- /// `[ CONSTRAINT <name> ] CHECK (<expr>) [[NOT] ENFORCED]`
81+ /// `[ CONSTRAINT <name> ] CHECK (<expr>) [NO INHERIT] [ [NOT] ENFORCED]`
8282 Check ( CheckConstraint ) ,
8383 /// MySQLs [index definition][1] for index creation. Not present on ANSI so, for now, the usage
8484 /// is restricted to MySQL, as no other dialects that support this syntax were found.
@@ -186,12 +186,15 @@ impl fmt::Display for TableConstraint {
186186#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
187187#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
188188#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
189- /// A `CHECK` constraint (`[ CONSTRAINT <name> ] CHECK (<expr>) [[NOT] ENFORCED]`).
189+ /// A `CHECK` constraint (`[ CONSTRAINT <name> ] CHECK (<expr>) [NO INHERIT] [ [NOT] ENFORCED]`).
190190pub struct CheckConstraint {
191191 /// Optional constraint name.
192192 pub name : Option < Ident > ,
193193 /// The boolean expression the CHECK constraint enforces.
194194 pub expr : Box < Expr > ,
195+ /// PostgreSQL-specific `NO INHERIT` flag: child tables do not inherit the constraint.
196+ /// <https://www.postgresql.org/docs/current/sql-createtable.html>
197+ pub no_inherit : bool ,
195198 /// MySQL-specific `ENFORCED` / `NOT ENFORCED` flag.
196199 /// <https://dev.mysql.com/doc/refman/8.4/en/create-table.html>
197200 pub enforced : Option < bool > ,
@@ -206,11 +209,13 @@ impl fmt::Display for CheckConstraint {
206209 display_constraint_name( & self . name) ,
207210 self . expr
208211 ) ?;
212+ if self . no_inherit {
213+ write ! ( f, " NO INHERIT" ) ?;
214+ }
209215 if let Some ( b) = self . enforced {
210- write ! ( f, " {}" , if b { "ENFORCED" } else { "NOT ENFORCED" } )
211- } else {
212- Ok ( ( ) )
216+ write ! ( f, " {}" , if b { "ENFORCED" } else { "NOT ENFORCED" } ) ?;
213217 }
218+ Ok ( ( ) )
214219 }
215220}
216221
0 commit comments