diff --git a/jOOQ/src/main/java/org/jooq/AlterDomainStep.java b/jOOQ/src/main/java/org/jooq/AlterDomainStep.java index a6e8409d2a..2b61f09a4e 100644 --- a/jOOQ/src/main/java/org/jooq/AlterDomainStep.java +++ b/jOOQ/src/main/java/org/jooq/AlterDomainStep.java @@ -71,24 +71,6 @@ public interface AlterDomainStep { @Support({ POSTGRES }) AlterDomainFinalStep add(Constraint addConstraint); - /** - * Add the DROP DEFAULT clause to the ALTER DOMAIN statement. - */ - @Support({ POSTGRES }) - AlterDomainFinalStep dropDefault(); - - /** - * Add the SET NOT NULL clause to the ALTER DOMAIN statement. - */ - @Support({ POSTGRES }) - AlterDomainFinalStep setNotNull(); - - /** - * Add the DROP NOT NULL clause to the ALTER DOMAIN statement. - */ - @Support({ POSTGRES }) - AlterDomainFinalStep dropNotNull(); - /** * Add the DROP CONSTRAINT clause to the ALTER DOMAIN statement. */ @@ -190,4 +172,22 @@ public interface AlterDomainStep { */ @Support({ POSTGRES }) AlterDomainFinalStep setDefault(Field setDefault); + + /** + * Add the DROP DEFAULT clause to the ALTER DOMAIN statement. + */ + @Support({ POSTGRES }) + AlterDomainFinalStep dropDefault(); + + /** + * Add the SET NOT NULL clause to the ALTER DOMAIN statement. + */ + @Support({ POSTGRES }) + AlterDomainFinalStep setNotNull(); + + /** + * Add the DROP NOT NULL clause to the ALTER DOMAIN statement. + */ + @Support({ POSTGRES }) + AlterDomainFinalStep dropNotNull(); } diff --git a/jOOQ/src/main/java/org/jooq/impl/AlterDatabaseImpl.java b/jOOQ/src/main/java/org/jooq/impl/AlterDatabaseImpl.java index fd89c1ec3b..c9e1a5c2f8 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AlterDatabaseImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/AlterDatabaseImpl.java @@ -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); diff --git a/jOOQ/src/main/java/org/jooq/impl/AlterDomainImpl.java b/jOOQ/src/main/java/org/jooq/impl/AlterDomainImpl.java index 223d3c3817..ea1434dcd6 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AlterDomainImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/AlterDomainImpl.java @@ -63,39 +63,39 @@ implements private static final long serialVersionUID = 1L; private final Domain 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 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 $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 $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 dropDefault() { - this.dropDefault = true; - return this; - } - - @Override - public final AlterDomainImpl setNotNull() { - this.setNotNull = true; - return this; - } - - @Override - public final AlterDomainImpl dropNotNull() { - this.dropNotNull = true; - return this; - } - @Override public final AlterDomainImpl dropConstraint(String dropConstraint) { return dropConstraint(DSL.constraint(dropConstraint)); @@ -274,6 +256,24 @@ implements return this; } + @Override + public final AlterDomainImpl dropDefault() { + this.dropDefault = true; + return this; + } + + @Override + public final AlterDomainImpl setNotNull() { + this.setNotNull = true; + return this; + } + + @Override + public final AlterDomainImpl dropNotNull() { + this.dropNotNull = true; + return this; + } + @Override public final AlterDomainImpl 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(' '); diff --git a/jOOQ/src/main/java/org/jooq/impl/AlterSchemaImpl.java b/jOOQ/src/main/java/org/jooq/impl/AlterSchemaImpl.java index 491558a101..32264ddb98 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AlterSchemaImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/AlterSchemaImpl.java @@ -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) diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateDatabaseImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateDatabaseImpl.java index 60b8e1c05f..2ab13b516f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateDatabaseImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateDatabaseImpl.java @@ -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); diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateDomainImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateDomainImpl.java index 0bcc02dbe5..67a7ba8d7d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateDomainImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateDomainImpl.java @@ -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 dataType; private Field default_; private Collection 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 $dataType() { return dataType; } - final Field $default_() { return default_; } - final Collection $constraints() { return constraints; } + final Domain $domain() { return domain; } + final boolean $createDomainIfNotExists() { return createDomainIfNotExists; } + final DataType $dataType() { return dataType; } + final Field $default_() { return default_; } + final Collection $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(' '); diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateSchemaImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateSchemaImpl.java index bfbb1925bf..523aa3f88e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateSchemaImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateSchemaImpl.java @@ -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) diff --git a/jOOQ/src/main/java/org/jooq/impl/DropDatabaseImpl.java b/jOOQ/src/main/java/org/jooq/impl/DropDatabaseImpl.java index df99bea50b..8283b429fa 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DropDatabaseImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/DropDatabaseImpl.java @@ -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); diff --git a/jOOQ/src/main/java/org/jooq/impl/DropDomainImpl.java b/jOOQ/src/main/java/org/jooq/impl/DropDomainImpl.java index d1b4588fcc..115accd70f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DropDomainImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/DropDomainImpl.java @@ -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); diff --git a/jOOQ/src/main/java/org/jooq/impl/DropSchemaImpl.java b/jOOQ/src/main/java/org/jooq/impl/DropSchemaImpl.java index c74b749244..3ffb8ab453 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DropSchemaImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/DropSchemaImpl.java @@ -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); diff --git a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java index 9ff4682634..ba61044e0c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java +++ b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java @@ -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);