[jOOQ/jOOQ#10210] Improved support for flags in DDL
This commit is contained in:
parent
c766fcdbfb
commit
ce73ad314a
@ -71,24 +71,6 @@ public interface AlterDomainStep<T> {
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep add(Constraint addConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP DEFAULT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep dropDefault();
|
||||
|
||||
/**
|
||||
* Add the <code>SET NOT NULL</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep setNotNull();
|
||||
|
||||
/**
|
||||
* Add the <code>DROP NOT NULL</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep dropNotNull();
|
||||
|
||||
/**
|
||||
* Add the <code>DROP CONSTRAINT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@ -190,4 +172,22 @@ public interface AlterDomainStep<T> {
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep setDefault(Field<T> setDefault);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP DEFAULT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep dropDefault();
|
||||
|
||||
/**
|
||||
* Add the <code>SET NOT NULL</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep setNotNull();
|
||||
|
||||
/**
|
||||
* Add the <code>DROP NOT NULL</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
AlterDomainFinalStep dropNotNull();
|
||||
}
|
||||
|
||||
@ -61,18 +61,18 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Catalog database;
|
||||
private final boolean ifExists;
|
||||
private final boolean alterDatabaseIfExists;
|
||||
private Catalog renameTo;
|
||||
|
||||
AlterDatabaseImpl(
|
||||
Configuration configuration,
|
||||
Catalog database,
|
||||
boolean ifExists
|
||||
boolean alterDatabaseIfExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
database,
|
||||
ifExists,
|
||||
alterDatabaseIfExists,
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -80,19 +80,19 @@ implements
|
||||
AlterDatabaseImpl(
|
||||
Configuration configuration,
|
||||
Catalog database,
|
||||
boolean ifExists,
|
||||
boolean alterDatabaseIfExists,
|
||||
Catalog renameTo
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.database = database;
|
||||
this.ifExists = ifExists;
|
||||
this.alterDatabaseIfExists = alterDatabaseIfExists;
|
||||
this.renameTo = renameTo;
|
||||
}
|
||||
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Catalog $renameTo() { return renameTo; }
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $alterDatabaseIfExists() { return alterDatabaseIfExists; }
|
||||
final Catalog $renameTo() { return renameTo; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
@ -132,7 +132,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
if (alterDatabaseIfExists && !supportsIfExists(ctx)) {
|
||||
Tools.beginTryCatch(ctx, DDLStatementType.ALTER_DATABASE);
|
||||
accept0(ctx);
|
||||
Tools.endTryCatch(ctx, DDLStatementType.ALTER_DATABASE);
|
||||
@ -151,7 +151,7 @@ implements
|
||||
|
||||
ctx.sql(' ').visit(K_DATABASE);
|
||||
|
||||
if (ifExists && supportsIfExists(ctx))
|
||||
if (alterDatabaseIfExists && supportsIfExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(database);
|
||||
|
||||
@ -63,39 +63,39 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Domain<T> domain;
|
||||
private final boolean ifExists;
|
||||
private final boolean alterDomainIfExists;
|
||||
private Constraint addConstraint;
|
||||
private boolean dropDefault;
|
||||
private boolean setNotNull;
|
||||
private boolean dropNotNull;
|
||||
private Constraint dropConstraint;
|
||||
private boolean dropConstraintIfExists;
|
||||
private Domain<?> renameTo;
|
||||
private Constraint renameConstraint;
|
||||
private boolean renameConstraintIfExists;
|
||||
private Field<T> setDefault;
|
||||
private boolean dropDefault;
|
||||
private boolean setNotNull;
|
||||
private boolean dropNotNull;
|
||||
private Boolean cascade;
|
||||
private Constraint renameConstraintTo;
|
||||
|
||||
AlterDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
boolean ifExists
|
||||
boolean alterDomainIfExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
domain,
|
||||
ifExists,
|
||||
alterDomainIfExists,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
null
|
||||
);
|
||||
@ -104,50 +104,50 @@ implements
|
||||
AlterDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
boolean ifExists,
|
||||
boolean alterDomainIfExists,
|
||||
Constraint addConstraint,
|
||||
boolean dropDefault,
|
||||
boolean setNotNull,
|
||||
boolean dropNotNull,
|
||||
Constraint dropConstraint,
|
||||
boolean dropConstraintIfExists,
|
||||
Domain renameTo,
|
||||
Constraint renameConstraint,
|
||||
boolean renameConstraintIfExists,
|
||||
Field setDefault,
|
||||
boolean dropDefault,
|
||||
boolean setNotNull,
|
||||
boolean dropNotNull,
|
||||
Boolean cascade,
|
||||
Constraint renameConstraintTo
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.domain = domain;
|
||||
this.ifExists = ifExists;
|
||||
this.alterDomainIfExists = alterDomainIfExists;
|
||||
this.addConstraint = addConstraint;
|
||||
this.dropDefault = dropDefault;
|
||||
this.setNotNull = setNotNull;
|
||||
this.dropNotNull = dropNotNull;
|
||||
this.dropConstraint = dropConstraint;
|
||||
this.dropConstraintIfExists = dropConstraintIfExists;
|
||||
this.renameTo = renameTo;
|
||||
this.renameConstraint = renameConstraint;
|
||||
this.renameConstraintIfExists = renameConstraintIfExists;
|
||||
this.setDefault = setDefault;
|
||||
this.dropDefault = dropDefault;
|
||||
this.setNotNull = setNotNull;
|
||||
this.dropNotNull = dropNotNull;
|
||||
this.cascade = cascade;
|
||||
this.renameConstraintTo = renameConstraintTo;
|
||||
}
|
||||
|
||||
final Domain<T> $domain() { return domain; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final boolean $alterDomainIfExists() { return alterDomainIfExists; }
|
||||
final Constraint $addConstraint() { return addConstraint; }
|
||||
final boolean $dropDefault() { return dropDefault; }
|
||||
final boolean $setNotNull() { return setNotNull; }
|
||||
final boolean $dropNotNull() { return dropNotNull; }
|
||||
final Constraint $dropConstraint() { return dropConstraint; }
|
||||
final boolean $dropConstraintIfExists() { return dropConstraintIfExists; }
|
||||
final Domain<?> $renameTo() { return renameTo; }
|
||||
final Constraint $renameConstraint() { return renameConstraint; }
|
||||
final boolean $renameConstraintIfExists() { return renameConstraintIfExists; }
|
||||
final Field<T> $setDefault() { return setDefault; }
|
||||
final boolean $dropDefault() { return dropDefault; }
|
||||
final boolean $setNotNull() { return setNotNull; }
|
||||
final boolean $dropNotNull() { return dropNotNull; }
|
||||
final Boolean $cascade() { return cascade; }
|
||||
final Constraint $renameConstraintTo() { return renameConstraintTo; }
|
||||
|
||||
@ -161,24 +161,6 @@ implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropDefault() {
|
||||
this.dropDefault = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> setNotNull() {
|
||||
this.setNotNull = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropNotNull() {
|
||||
this.dropNotNull = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropConstraint(String dropConstraint) {
|
||||
return dropConstraint(DSL.constraint(dropConstraint));
|
||||
@ -274,6 +256,24 @@ implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropDefault() {
|
||||
this.dropDefault = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> setNotNull() {
|
||||
this.setNotNull = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropNotNull() {
|
||||
this.dropNotNull = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> cascade() {
|
||||
this.cascade = true;
|
||||
@ -330,7 +330,7 @@ implements
|
||||
|
||||
ctx.visit(K_ALTER).sql(' ').visit(K_DOMAIN).sql(' ');
|
||||
|
||||
if (ifExists)
|
||||
if (alterDomainIfExists)
|
||||
ctx.visit(K_IF_EXISTS).sql(' ');
|
||||
|
||||
ctx.visit(domain).sql(' ');
|
||||
|
||||
@ -61,18 +61,18 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Schema schema;
|
||||
private final boolean ifExists;
|
||||
private final boolean alterSchemaIfExists;
|
||||
private Schema renameTo;
|
||||
|
||||
AlterSchemaImpl(
|
||||
Configuration configuration,
|
||||
Schema schema,
|
||||
boolean ifExists
|
||||
boolean alterSchemaIfExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
schema,
|
||||
ifExists,
|
||||
alterSchemaIfExists,
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -80,19 +80,19 @@ implements
|
||||
AlterSchemaImpl(
|
||||
Configuration configuration,
|
||||
Schema schema,
|
||||
boolean ifExists,
|
||||
boolean alterSchemaIfExists,
|
||||
Schema renameTo
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.schema = schema;
|
||||
this.ifExists = ifExists;
|
||||
this.alterSchemaIfExists = alterSchemaIfExists;
|
||||
this.renameTo = renameTo;
|
||||
}
|
||||
|
||||
final Schema $schema() { return schema; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Schema $renameTo() { return renameTo; }
|
||||
final Schema $schema() { return schema; }
|
||||
final boolean $alterSchemaIfExists() { return alterSchemaIfExists; }
|
||||
final Schema $renameTo() { return renameTo; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
@ -158,7 +158,7 @@ implements
|
||||
else
|
||||
ctx.visit(K_ALTER_SCHEMA);
|
||||
|
||||
if (ifExists)
|
||||
if (alterSchemaIfExists)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -60,22 +60,22 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Catalog database;
|
||||
private final boolean ifNotExists;
|
||||
private final boolean createDatabaseIfNotExists;
|
||||
|
||||
|
||||
CreateDatabaseImpl(
|
||||
Configuration configuration,
|
||||
Catalog database,
|
||||
boolean ifNotExists
|
||||
boolean createDatabaseIfNotExists
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.database = database;
|
||||
this.ifNotExists = ifNotExists;
|
||||
this.createDatabaseIfNotExists = createDatabaseIfNotExists;
|
||||
}
|
||||
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $ifNotExists() { return ifNotExists; }
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $createDatabaseIfNotExists() { return createDatabaseIfNotExists; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
@ -91,7 +91,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifNotExists && !supportsIfNotExists(ctx)) {
|
||||
if (createDatabaseIfNotExists && !supportsIfNotExists(ctx)) {
|
||||
Tools.beginTryCatch(ctx, DDLStatementType.CREATE_DATABASE);
|
||||
accept0(ctx);
|
||||
Tools.endTryCatch(ctx, DDLStatementType.CREATE_DATABASE);
|
||||
@ -104,7 +104,7 @@ implements
|
||||
private final void accept0(Context<?> ctx) {
|
||||
ctx.visit(K_CREATE).sql(' ').visit(K_DATABASE);
|
||||
|
||||
if (ifNotExists && supportsIfNotExists(ctx))
|
||||
if (createDatabaseIfNotExists && supportsIfNotExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_NOT_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(database);
|
||||
|
||||
@ -63,7 +63,7 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Domain<?> domain;
|
||||
private final boolean ifNotExists;
|
||||
private final boolean createDomainIfNotExists;
|
||||
private DataType<T> dataType;
|
||||
private Field<T> default_;
|
||||
private Collection<? extends Constraint> constraints;
|
||||
@ -71,12 +71,12 @@ implements
|
||||
CreateDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
boolean ifNotExists
|
||||
boolean createDomainIfNotExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
domain,
|
||||
ifNotExists,
|
||||
createDomainIfNotExists,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
@ -86,7 +86,7 @@ implements
|
||||
CreateDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
boolean ifNotExists,
|
||||
boolean createDomainIfNotExists,
|
||||
DataType dataType,
|
||||
Field default_,
|
||||
Collection constraints
|
||||
@ -94,17 +94,17 @@ implements
|
||||
super(configuration);
|
||||
|
||||
this.domain = domain;
|
||||
this.ifNotExists = ifNotExists;
|
||||
this.createDomainIfNotExists = createDomainIfNotExists;
|
||||
this.dataType = dataType;
|
||||
this.default_ = default_;
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
final Domain<?> $domain() { return domain; }
|
||||
final boolean $ifNotExists() { return ifNotExists; }
|
||||
final DataType<T> $dataType() { return dataType; }
|
||||
final Field<T> $default_() { return default_; }
|
||||
final Collection<? extends Constraint> $constraints() { return constraints; }
|
||||
final Domain<?> $domain() { return domain; }
|
||||
final boolean $createDomainIfNotExists() { return createDomainIfNotExists; }
|
||||
final DataType<T> $dataType() { return dataType; }
|
||||
final Field<T> $default_() { return default_; }
|
||||
final Collection<? extends Constraint> $constraints() { return constraints; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
@ -157,7 +157,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifNotExists && !supportsIfNotExists(ctx)) {
|
||||
if (createDomainIfNotExists && !supportsIfNotExists(ctx)) {
|
||||
Tools.beginTryCatch(ctx, DDLStatementType.CREATE_DOMAIN);
|
||||
accept0(ctx);
|
||||
Tools.endTryCatch(ctx, DDLStatementType.CREATE_DOMAIN);
|
||||
@ -177,7 +177,7 @@ implements
|
||||
default:
|
||||
ctx.visit(K_CREATE).sql(' ').visit(K_DOMAIN);
|
||||
|
||||
if (ifNotExists && supportsIfNotExists(ctx))
|
||||
if (createDomainIfNotExists && supportsIfNotExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_NOT_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(domain).sql(' ').visit(K_AS).sql(' ');
|
||||
|
||||
@ -60,22 +60,22 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Schema schema;
|
||||
private final boolean ifNotExists;
|
||||
private final boolean createSchemaIfNotExists;
|
||||
|
||||
|
||||
CreateSchemaImpl(
|
||||
Configuration configuration,
|
||||
Schema schema,
|
||||
boolean ifNotExists
|
||||
boolean createSchemaIfNotExists
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.schema = schema;
|
||||
this.ifNotExists = ifNotExists;
|
||||
this.createSchemaIfNotExists = createSchemaIfNotExists;
|
||||
}
|
||||
|
||||
final Schema $schema() { return schema; }
|
||||
final boolean $ifNotExists() { return ifNotExists; }
|
||||
final Schema $schema() { return schema; }
|
||||
final boolean $createSchemaIfNotExists() { return createSchemaIfNotExists; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
@ -97,7 +97,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifNotExists && !supportsIfNotExists(ctx)) {
|
||||
if (createSchemaIfNotExists && !supportsIfNotExists(ctx)) {
|
||||
Tools.beginTryCatch(ctx, DDLStatementType.CREATE_SCHEMA);
|
||||
accept0(ctx);
|
||||
Tools.endTryCatch(ctx, DDLStatementType.CREATE_SCHEMA);
|
||||
@ -135,7 +135,7 @@ implements
|
||||
|
||||
ctx.sql(' ').visit(K_SCHEMA);
|
||||
|
||||
if (ifNotExists && supportsIfNotExists(ctx))
|
||||
if (createSchemaIfNotExists && supportsIfNotExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_NOT_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(schema)
|
||||
|
||||
@ -60,22 +60,22 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Catalog database;
|
||||
private final boolean ifExists;
|
||||
private final boolean dropDatabaseIfExists;
|
||||
|
||||
|
||||
DropDatabaseImpl(
|
||||
Configuration configuration,
|
||||
Catalog database,
|
||||
boolean ifExists
|
||||
boolean dropDatabaseIfExists
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.database = database;
|
||||
this.ifExists = ifExists;
|
||||
this.dropDatabaseIfExists = dropDatabaseIfExists;
|
||||
}
|
||||
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $dropDatabaseIfExists() { return dropDatabaseIfExists; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
@ -91,7 +91,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
if (dropDatabaseIfExists && !supportsIfExists(ctx)) {
|
||||
Tools.beginTryCatch(ctx, DDLStatementType.DROP_DATABASE);
|
||||
accept0(ctx);
|
||||
Tools.endTryCatch(ctx, DDLStatementType.DROP_DATABASE);
|
||||
@ -104,7 +104,7 @@ implements
|
||||
private void accept0(Context<?> ctx) {
|
||||
ctx.visit(K_DROP).sql(' ').visit(K_DATABASE);
|
||||
|
||||
if (ifExists && supportsIfExists(ctx))
|
||||
if (dropDatabaseIfExists && supportsIfExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(database);
|
||||
|
||||
@ -61,18 +61,18 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Domain<?> domain;
|
||||
private final boolean ifExists;
|
||||
private final boolean dropDomainIfExists;
|
||||
private Boolean cascade;
|
||||
|
||||
DropDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
boolean ifExists
|
||||
boolean dropDomainIfExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
domain,
|
||||
ifExists,
|
||||
dropDomainIfExists,
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -80,19 +80,19 @@ implements
|
||||
DropDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
boolean ifExists,
|
||||
boolean dropDomainIfExists,
|
||||
Boolean cascade
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.domain = domain;
|
||||
this.ifExists = ifExists;
|
||||
this.dropDomainIfExists = dropDomainIfExists;
|
||||
this.cascade = cascade;
|
||||
}
|
||||
|
||||
final Domain<?> $domain() { return domain; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Boolean $cascade() { return cascade; }
|
||||
final Domain<?> $domain() { return domain; }
|
||||
final boolean $dropDomainIfExists() { return dropDomainIfExists; }
|
||||
final Boolean $cascade() { return cascade; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
@ -130,7 +130,7 @@ implements
|
||||
break;
|
||||
}
|
||||
|
||||
if (ifExists)
|
||||
if (dropDomainIfExists)
|
||||
ctx.sql(' ').visit(K_IF_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(domain);
|
||||
|
||||
@ -61,18 +61,18 @@ implements
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Schema schema;
|
||||
private final boolean ifExists;
|
||||
private final boolean dropSchemaIfExists;
|
||||
private Boolean cascade;
|
||||
|
||||
DropSchemaImpl(
|
||||
Configuration configuration,
|
||||
Schema schema,
|
||||
boolean ifExists
|
||||
boolean dropSchemaIfExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
schema,
|
||||
ifExists,
|
||||
dropSchemaIfExists,
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -80,19 +80,19 @@ implements
|
||||
DropSchemaImpl(
|
||||
Configuration configuration,
|
||||
Schema schema,
|
||||
boolean ifExists,
|
||||
boolean dropSchemaIfExists,
|
||||
Boolean cascade
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.schema = schema;
|
||||
this.ifExists = ifExists;
|
||||
this.dropSchemaIfExists = dropSchemaIfExists;
|
||||
this.cascade = cascade;
|
||||
}
|
||||
|
||||
final Schema $schema() { return schema; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Boolean $cascade() { return cascade; }
|
||||
final Schema $schema() { return schema; }
|
||||
final boolean $dropSchemaIfExists() { return dropSchemaIfExists; }
|
||||
final Boolean $cascade() { return cascade; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
@ -131,7 +131,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (ifExists && !supportsIfExists(ctx)) {
|
||||
if (dropSchemaIfExists && !supportsIfExists(ctx)) {
|
||||
Tools.beginTryCatch(ctx, DDLStatementType.DROP_SCHEMA);
|
||||
accept0(ctx);
|
||||
Tools.endTryCatch(ctx, DDLStatementType.DROP_SCHEMA);
|
||||
@ -152,14 +152,14 @@ implements
|
||||
|
||||
ctx.sql(' ').visit(K_SCHEMA);
|
||||
|
||||
if (ifExists && supportsIfExists(ctx))
|
||||
if (dropSchemaIfExists && supportsIfExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(schema);
|
||||
|
||||
if (cascade)
|
||||
if (cascade != null && cascade)
|
||||
ctx.sql(' ').visit(K_CASCADE);
|
||||
else if (REQUIRES_RESTRICT.contains(ctx.family()))
|
||||
else if (cascade != null && !cascade || REQUIRES_RESTRICT.contains(ctx.family()))
|
||||
ctx.sql(' ').visit(K_RESTRICT);
|
||||
|
||||
ctx.end(Clause.DROP_SCHEMA_SCHEMA);
|
||||
|
||||
@ -247,7 +247,7 @@ final class Interpreter {
|
||||
Schema schema = query.$schema();
|
||||
|
||||
if (getSchema(schema, false) != null) {
|
||||
if (!query.$ifNotExists())
|
||||
if (!query.$createSchemaIfNotExists())
|
||||
throw schemaAlreadyExists(schema);
|
||||
|
||||
return;
|
||||
@ -262,7 +262,7 @@ final class Interpreter {
|
||||
|
||||
MutableSchema oldSchema = getSchema(schema);
|
||||
if (oldSchema == null) {
|
||||
if (!query.$ifExists())
|
||||
if (!query.$alterSchemaIfExists())
|
||||
throw schemaNotExists(schema);
|
||||
|
||||
return;
|
||||
@ -284,13 +284,13 @@ final class Interpreter {
|
||||
MutableSchema mutableSchema = getSchema(schema);
|
||||
|
||||
if (mutableSchema == null) {
|
||||
if (!query.$ifExists())
|
||||
if (!query.$dropSchemaIfExists())
|
||||
throw schemaNotExists(schema);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mutableSchema.isEmpty() || query.$cascade())
|
||||
if (mutableSchema.isEmpty() || TRUE.equals(query.$cascade()))
|
||||
mutableSchema.catalog.schemas.remove(mutableSchema);
|
||||
else
|
||||
throw schemaNotEmpty(schema);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user