diff --git a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt index 783a5701d..592c96ace 100644 --- a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt +++ b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt @@ -3593,7 +3593,7 @@ AlterExpression AlterExpression(): List columnNames = null; List constraints = null; ForeignKeyIndex fkIndex = null; - NamedConstraint index = null; + Index index = null; Table fkTable = null; AlterExpression.ColumnDataType alterExpressionColumnDataType = null; } @@ -3604,20 +3604,19 @@ AlterExpression AlterExpression(): ( LOOKAHEAD(2) ( columnNames=ColumnsNamesList() { alterExp.setPkColumns(columnNames); } ) constraints=AlterExpressionConstraintState() { alterExp.setConstraints(constraints); } | - LOOKAHEAD(2) ( - tk= - sk3=ColumnsNamesListItem() - { - columnNames = new ArrayList(); - columnNames.add(sk3); - - index = new NamedConstraint(); - index.setType(tk.image); - index.setColumnsNames(columnNames); - alterExp.setIndex(index); - } - constraints=AlterExpressionConstraintState() { alterExp.setConstraints(constraints); } - ) + LOOKAHEAD(2) ( + tk = < K_INDEX > + sk3 = RelObjectName() + columnNames = ColumnsNamesList() + { + index = new Index(); + index.setType(tk.image); + index.setName(sk3); + index.setColumnsNames(columnNames); + alterExp.setIndex(index); + } + constraints=AlterExpressionConstraintState() { alterExp.setConstraints(constraints); } + ) | ( (LOOKAHEAD(2) )? alterExpressionColumnDataType = AlterExpressionColumnDataType() { alterExp.addColDataType(alterExpressionColumnDataType); } diff --git a/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java b/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java index cf17f70be..2438de1ac 100644 --- a/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java +++ b/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import org.junit.Ignore; import org.junit.Test; public class AlterTest { @@ -313,8 +312,7 @@ public void testIssue633() throws JSQLParserException { } @Test - @Ignore public void testIssue679() throws JSQLParserException { - assertSqlCanBeParsedAndDeparsed("ALTER TABLE tb_session_status ADD INDEX idx_user_id(user_id)"); + assertSqlCanBeParsedAndDeparsed("ALTER TABLE tb_session_status ADD INDEX idx_user_id_name (user_id, user_name(10)), ADD INDEX idx_user_name (user_name)"); } }