diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt b/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt index 2ec374fda8..6d6c6bed15 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt +++ b/jOOQ-manual/src/main/resources/org/jooq/web/grammar-3.11.txt @@ -122,7 +122,8 @@ break ; createIndexStatement = 'CREATE' [ 'UNIQUE' ] 'INDEX' [ 'IF NOT EXISTS' ] [ indexName ] break - 'ON' tableName '(' identifiers ')' + 'ON' tableName '(' sortFields ')' + [ 'INCLUDE' '(' identifiers ')' ] [ 'WHERE' condition ] ; diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index cf537dd11e..af0625f648 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -279,6 +279,7 @@ import org.jooq.Constraint; import org.jooq.ConstraintForeignKeyOnStep; import org.jooq.ConstraintTypeStep; import org.jooq.CreateIndexFinalStep; +import org.jooq.CreateIndexIncludeStep; import org.jooq.CreateIndexStep; import org.jooq.CreateIndexWhereStep; import org.jooq.CreateTableAsStep; @@ -3051,11 +3052,18 @@ final class ParserImpl implements Parser { parse(ctx, '('); SortField[] fields = parseSortSpecification(ctx).toArray(EMPTY_SORTFIELD); parse(ctx, ')'); + + Name[] include = null; + if (parseKeywordIf(ctx, "INCLUDE")) { + parse(ctx, '('); + include = parseIdentifiers(ctx).toArray(EMPTY_NAME); + parse(ctx, ')'); + } + Condition condition = parseKeywordIf(ctx, "WHERE") ? parseCondition(ctx) : null; - CreateIndexStep s1 = ifNotExists ? unique ? ctx.dsl.createUniqueIndexIfNotExists(indexName) @@ -3068,12 +3076,15 @@ final class ParserImpl implements Parser { ? ctx.dsl.createIndex() : ctx.dsl.createIndex(indexName); - CreateIndexWhereStep s2 = s1.on(tableName, fields); - CreateIndexFinalStep s3 = condition != null - ? s2.where(condition) + CreateIndexIncludeStep s2 = s1.on(tableName, fields); + CreateIndexWhereStep s3 = include != null + ? s2.include(include) : s2; + CreateIndexFinalStep s4 = condition != null + ? s3.where(condition) + : s3; - return s3; + return s4; } private static final DDLQuery parseAlterDomain(ParserContext ctx) {