Skip to content

Commit b5adb60

Browse files
authored
fix: support SQL Server CREATE INDEX INCLUDE columns (#2462)
- fixes #2462
1 parent c9930e3 commit b5adb60

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10507,6 +10507,7 @@ CreateIndex CreateIndex():
1050710507
CreateIndex createIndex = new CreateIndex();
1050810508
Table table = null;
1050910509
List<Index.ColumnParams> colNames;
10510+
List<String> includeColumns;
1051010511
String indexType;
1051110512
Index index = null;
1051210513
List<String> parameter = new ArrayList<String>();
@@ -10535,6 +10536,9 @@ CreateIndex CreateIndex():
1053510536
)
1053610537
)
1053710538
colNames = IndexColumnsWithParamsList()
10539+
[ <K_INCLUDE> includeColumns=ColumnsNamesList()
10540+
{ tailParameters.add("INCLUDE (" + String.join(", ", includeColumns) + ")"); }
10541+
]
1053810542
( LOOKAHEAD(2) parameter=CreateParameter() { tailParameters.addAll(parameter); } )*
1053910543
{
1054010544
index.setColumns(colNames);

src/test/java/net/sf/jsqlparser/statement/create/CreateIndexTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,9 @@ public void testCreateIndexVisibility() throws JSQLParserException {
174174
assertSqlCanBeParsedAndDeparsed("CREATE INDEX idx_a ON t1 (a) INVISIBLE", true);
175175
assertSqlCanBeParsedAndDeparsed("CREATE INDEX idx_a ON t1 (a) VISIBLE", true);
176176
}
177+
178+
@Test
179+
public void testCreateIndexIncludeIssue2459() throws JSQLParserException {
180+
assertSqlCanBeParsedAndDeparsed("CREATE INDEX idx_a ON t1 (a) INCLUDE (b, c)");
181+
}
177182
}

0 commit comments

Comments
 (0)