File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
main/jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/alter Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -4420,6 +4420,10 @@ AlterExpression AlterExpression():
44204420 fkIndex.setReferencedColumnNames(columnNames);
44214421 alterExp.setIndex(fkIndex);
44224422 }
4423+ [<K_ON> <K_DELETE>
4424+ (<K_CASCADE> { fkIndex.setOnDeleteReferenceOption("CASCADE"); }
4425+ | <K_RESTRICT> { fkIndex.setOnDeleteReferenceOption("RESTRICT"); }
4426+ | <K_SET> <K_NULL> { fkIndex.setOnDeleteReferenceOption("SET NULL"); } ) ]
44234427 constraints=AlterExpressionConstraintState() { alterExp.setConstraints(constraints); }
44244428 )
44254429 |
Original file line number Diff line number Diff line change @@ -414,4 +414,19 @@ public void testAlterTableRenameColumn() throws JSQLParserException {
414414 assertEquals (expression .getColOldName (), "\" test_column\" " );
415415 assertEquals (expression .getColumnName (), "\" test_c\" " );
416416 }
417+
418+ @ Test
419+ public void testAlterTableForeignKeyIssue981 () throws JSQLParserException {
420+ assertSqlCanBeParsedAndDeparsed (
421+ "ALTER TABLE atconfigpro " +
422+ "ADD CONSTRAINT atconfigpro_atconfignow_id_foreign FOREIGN KEY (atconfignow_id) REFERENCES atconfignow(id) ON DELETE CASCADE, " +
423+ "ADD CONSTRAINT atconfigpro_attariff_id_foreign FOREIGN KEY (attariff_id) REFERENCES attariff(id) ON DELETE CASCADE" );
424+ }
425+
426+ @ Test
427+ public void testAlterTableForeignKeyIssue981_2 () throws JSQLParserException {
428+ assertSqlCanBeParsedAndDeparsed (
429+ "ALTER TABLE atconfigpro " +
430+ "ADD CONSTRAINT atconfigpro_atconfignow_id_foreign FOREIGN KEY (atconfignow_id) REFERENCES atconfignow(id) ON DELETE CASCADE" );
431+ }
417432}
You can’t perform that action at this time.
0 commit comments