use of org.jooq.AlterDomainDropConstraintCascadeStep in project jOOQ by jOOQ.
the class DefaultParseContext method parseAlterDomain.
private final DDLQuery parseAlterDomain() {
boolean ifExists = parseKeywordIf("IF EXISTS");
Domain<?> domainName = parseDomainName();
AlterDomainStep s1 = ifExists ? dsl.alterDomainIfExists(domainName) : dsl.alterDomain(domainName);
if (parseKeywordIf("ADD")) {
ConstraintTypeStep constraint = parseConstraintNameSpecification();
// TODO: NOT NULL constraints
if (parseKeywordIf("CHECK"))
return s1.add(parseCheckSpecification(constraint));
else
throw expected("CHECK", "CONSTRAINT");
} else if (parseKeywordIf("DROP CONSTRAINT")) {
boolean ifConstraintExists = parseKeywordIf("IF EXISTS");
Constraint constraint = constraint(parseIdentifier());
AlterDomainDropConstraintCascadeStep s2 = ifConstraintExists ? s1.dropConstraintIfExists(constraint) : s1.dropConstraint(constraint);
return parseKeywordIf("CASCADE") ? s2.cascade() : parseKeywordIf("RESTRICT") ? s2.restrict() : s2;
} else if (parseKeywordIf("RENAME")) {
if (parseKeywordIf("TO") || parseKeywordIf("AS")) {
return s1.renameTo(parseDomainName());
} else if (parseKeywordIf("CONSTRAINT")) {
boolean ifConstraintExists = parseKeywordIf("IF EXISTS");
Constraint oldName = constraint(parseIdentifier());
AlterDomainRenameConstraintStep s2 = ifConstraintExists ? s1.renameConstraintIfExists(oldName) : s1.renameConstraint(oldName);
parseKeyword("AS", "TO");
return s2.to(constraint(parseIdentifier()));
} else
throw expected("CONSTRAINT", "TO", "AS");
} else if (parseKeywordIf("SET DEFAULT"))
return s1.setDefault(parseField());
else if (parseKeywordIf("DROP DEFAULT"))
return s1.dropDefault();
else if (parseKeywordIf("SET NOT NULL"))
return s1.setNotNull();
else if (parseKeywordIf("DROP NOT NULL"))
return s1.dropNotNull();
else if (parseKeywordIf("OWNER TO")) {
parseUser();
return IGNORE;
} else
throw expected("ADD", "DROP", "RENAME", "SET", "OWNER TO");
}
Aggregations