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():
4420
4420
fkIndex.setReferencedColumnNames(columnNames);
4421
4421
alterExp.setIndex(fkIndex);
4422
4422
}
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"); } ) ]
4423
4427
constraints=AlterExpressionConstraintState() { alterExp.setConstraints(constraints); }
4424
4428
)
4425
4429
|
Original file line number Diff line number Diff line change @@ -414,4 +414,19 @@ public void testAlterTableRenameColumn() throws JSQLParserException {
414
414
assertEquals (expression .getColOldName (), "\" test_column\" " );
415
415
assertEquals (expression .getColumnName (), "\" test_c\" " );
416
416
}
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
+ }
417
432
}
You can’t perform that action at this time.
0 commit comments