use of org.jooq.CreateDomainConstraintStep in project jOOQ by jOOQ.
the class DefaultParseContext method parseCreateDomain.
private final DDLQuery parseCreateDomain() {
boolean ifNotExists = parseKeywordIf("IF NOT EXISTS");
Domain<?> domainName = parseDomainName();
parseKeyword("AS");
DataType<?> dataType = parseDataType();
CreateDomainDefaultStep<?> s1 = ifNotExists ? dsl.createDomainIfNotExists(domainName).as(dataType) : dsl.createDomain(domainName).as(dataType);
CreateDomainConstraintStep s2 = parseKeywordIf("DEFAULT") ? s1.default_((Field) parseField()) : s1;
List<Constraint> constraints = new ArrayList<>();
constraintLoop: for (; ; ) {
ConstraintTypeStep constraint = parseConstraintNameSpecification();
// TODO: NOT NULL constraints
if (parseKeywordIf("CHECK")) {
constraints.add(parseCheckSpecification(constraint));
continue constraintLoop;
} else if (constraint != null)
throw expected("CHECK", "CONSTRAINT");
break;
}
if (!constraints.isEmpty())
s2 = s2.constraints(constraints);
return s2;
}
use of org.jooq.CreateDomainConstraintStep in project jOOQ by jOOQ.
the class DDL method createDomain.
@SuppressWarnings({ "rawtypes", "unchecked" })
final Query createDomain(Domain<?> domain) {
CreateDomainAsStep s1 = configuration.createDomainIfNotExists() ? ctx.createDomainIfNotExists(domain) : ctx.createDomain(domain);
CreateDomainDefaultStep s2 = s1.as(domain.getDataType());
CreateDomainConstraintStep s3 = domain.getDataType().defaulted() ? s2.default_(domain.getDataType().default_()) : s2;
if (domain.getChecks().isEmpty())
return s3;
return s3.constraints(map(domain.getChecks(), c -> c.constraint()));
}
Aggregations