Skip to content

Commit

Permalink
Alter table add constraint check (#4120)
Browse files Browse the repository at this point in the history
* Alter table add constraint check for MySql Dialect

Update mysql grammer support for table add constraint check

uses inherited check_constraint expression

* Alter table add constraint check for MySql Dialect

Add test fixture

* Alter table add constraint check for PostgreSql Dialect

Add test fixture

* Alter table add constraint check for PostgreSql Dialect

Update postgressql grammer support for table add constraint check

uses inherited check_constraint expression
  • Loading branch information
griffio committed Apr 28, 2023
1 parent 149bad6 commit c8784ac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bind_parameter ::= DEFAULT | ( '?' | ':' {identifier} ) {
}
table_constraint ::= [ CONSTRAINT {identifier} ] (
( PRIMARY KEY | [ UNIQUE | 'FULLTEXT' ] KEY | [ UNIQUE | 'FULLTEXT' ] [ INDEX ] ) [{index_name}] LP {indexed_column} [ LP {signed_number} RP ] ( COMMA {indexed_column} [ LP {signed_number} RP ] ) * RP {conflict_clause} [comment_type] |
CHECK LP expr RP |
{check_constraint} |
FOREIGN KEY LP {column_name} ( COMMA {column_name} ) * RP {foreign_key_clause}
) {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlTableConstraintImpl"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE t1 (
c1 int(11)
);

ALTER TABLE t1
ADD CONSTRAINT chk_c1 CHECK (c1 > 0);
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ bind_parameter ::= DEFAULT | ( '?' | ':' {identifier} ) {
}
table_constraint ::= [ CONSTRAINT {identifier} ] (
( PRIMARY KEY | UNIQUE ) [{index_name}] LP {indexed_column} [ LP {signed_number} RP ] ( COMMA {indexed_column} [ LP {signed_number} RP ] ) * RP {conflict_clause} [comment_type] |
{check_constraint} |
FOREIGN KEY LP {column_name} ( COMMA {column_name} ) * RP {foreign_key_clause}
) {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlTableConstraintImpl"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE t1 (
c1 INTEGER
);

ALTER TABLE t1
ADD CONSTRAINT chk_c1 CHECK (c1 > 0);

0 comments on commit c8784ac

Please sign in to comment.