use of org.jooq.CreateIndexStep in project jOOQ by jOOQ.
the class ParserImpl method parseCreateIndex.
private static final DDLQuery parseCreateIndex(ParserContext ctx) {
boolean ifNotExists = parseKeywordIf(ctx, "IF NOT EXISTS");
Name indexName = parseIndexName(ctx);
parseKeyword(ctx, "ON");
Table<?> tableName = parseTableName(ctx);
parse(ctx, '(');
Field<?>[] fieldNames = Tools.fieldsByName(parseIdentifiers(ctx));
parse(ctx, ')');
Condition condition = parseKeywordIf(ctx, "WHERE") ? parseCondition(ctx) : null;
CreateIndexStep s1 = ifNotExists ? ctx.dsl.createIndexIfNotExists(indexName) : ctx.dsl.createIndex(indexName);
CreateIndexWhereStep s2 = s1.on(tableName, fieldNames);
CreateIndexFinalStep s3 = condition != null ? s2.where(condition) : s2;
return s3;
}
use of org.jooq.CreateIndexStep 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;
}
Aggregations