Search in sources :

Example 1 with CreateIndexIncludeStep

use of org.jooq.CreateIndexIncludeStep in project jOOQ by jOOQ.

the class DefaultParseContext method parseCreateIndex.

private final DDLQuery parseCreateIndex(boolean unique) {
    boolean ifNotExists = parseKeywordIf("IF NOT EXISTS");
    Name indexName = parseIndexNameIf();
    parseUsingIndexTypeIf();
    SortField<?>[] fields = null;
    if (peek('('))
        fields = parseParenthesisedSortSpecification();
    parseKeyword("ON");
    Table<?> tableName = parseTableName();
    parseUsingIndexTypeIf();
    if (fields == null)
        fields = parseParenthesisedSortSpecification();
    parseUsingIndexTypeIf();
    Name[] include = null;
    if (parseKeywordIf("INCLUDE") || parseKeywordIf("COVERING") || parseKeywordIf("STORING")) {
        parse('(');
        include = parseIdentifiers().toArray(EMPTY_NAME);
        parse(')');
    }
    Condition condition = parseKeywordIf("WHERE") ? parseCondition() : null;
    boolean excludeNullKeys = condition == null && parseKeywordIf("EXCLUDE NULL KEYS");
    CreateIndexStep s1 = ifNotExists ? unique ? dsl.createUniqueIndexIfNotExists(indexName) : dsl.createIndexIfNotExists(indexName) : unique ? indexName == null ? dsl.createUniqueIndex() : dsl.createUniqueIndex(indexName) : indexName == null ? dsl.createIndex() : dsl.createIndex(indexName);
    CreateIndexIncludeStep s2 = s1.on(tableName, fields);
    CreateIndexWhereStep s3 = include != null ? s2.include(include) : s2;
    return condition != null ? s3.where(condition) : excludeNullKeys ? s3.excludeNullKeys() : s3;
}
Also used : Condition(org.jooq.Condition) CreateIndexIncludeStep(org.jooq.CreateIndexIncludeStep) SortField(org.jooq.SortField) CreateIndexWhereStep(org.jooq.CreateIndexWhereStep) CreateIndexStep(org.jooq.CreateIndexStep) Name(org.jooq.Name) DSL.systemName(org.jooq.impl.DSL.systemName)

Aggregations

Condition (org.jooq.Condition)1 CreateIndexIncludeStep (org.jooq.CreateIndexIncludeStep)1 CreateIndexStep (org.jooq.CreateIndexStep)1 CreateIndexWhereStep (org.jooq.CreateIndexWhereStep)1 Name (org.jooq.Name)1 SortField (org.jooq.SortField)1 DSL.systemName (org.jooq.impl.DSL.systemName)1