[jOOQ/jOOQ#10210] Improved API generation
- Generate CreateSchemaImpl - Don't change API to be immutable (yet) - Generate () accessors for Interpreter
This commit is contained in:
parent
cd67be658d
commit
19c2b28237
@ -37,8 +37,12 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A {@link Query} that can create schemas.
|
||||
* A step in the construction of the CREATE SCHEMA statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -57,9 +61,7 @@ package org.jooq;
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface CreateSchemaFinalStep extends DDLQuery {
|
||||
|
||||
}
|
||||
|
||||
@ -8836,6 +8836,54 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
@Support({ H2, POSTGRES })
|
||||
CreateDomainAsStep createDomainIfNotExists(Domain<?> domain);
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchema(String)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchema(String schema);
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchema(Name)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchema(Name schema);
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchema(Schema)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchema(Schema schema);
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA IF NOT EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#createSchemaIfNotExists(String)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchemaIfNotExists(String schema);
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA IF NOT EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#createSchemaIfNotExists(Name)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchemaIfNotExists(Name schema);
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA IF NOT EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#createSchemaIfNotExists(Schema)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchemaIfNotExists(Schema schema);
|
||||
|
||||
/**
|
||||
* The <code>ALTER DATABASE</code> statement.
|
||||
*
|
||||
@ -9100,54 +9148,6 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
CommentOnIsStep commentOnColumn(Field<?> field);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchema(String)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchema(String schema);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchema(Name)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchema(Name schema);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchema(Schema)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchema(Schema schema);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchemaIfNotExists(String)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchemaIfNotExists(String schema);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchemaIfNotExists(Name)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchemaIfNotExists(Name schema);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSL#createSchemaIfNotExists(Schema)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
CreateSchemaFinalStep createSchemaIfNotExists(Schema schema);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE TABLE</code> statement.
|
||||
*
|
||||
|
||||
@ -62,7 +62,7 @@ implements
|
||||
|
||||
private final Catalog database;
|
||||
private final boolean ifExists;
|
||||
private final Catalog renameTo;
|
||||
private Catalog renameTo;
|
||||
|
||||
AlterDatabaseImpl(
|
||||
Configuration configuration,
|
||||
@ -90,6 +90,10 @@ implements
|
||||
this.renameTo = renameTo;
|
||||
}
|
||||
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Catalog $renameTo() { return renameTo; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
@ -106,12 +110,8 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDatabaseImpl renameTo(Catalog renameTo) {
|
||||
return new AlterDatabaseImpl(
|
||||
configuration(),
|
||||
this.database,
|
||||
this.ifExists,
|
||||
renameTo
|
||||
);
|
||||
this.renameTo = renameTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -64,18 +64,18 @@ implements
|
||||
|
||||
private final Domain<T> domain;
|
||||
private final boolean ifExists;
|
||||
private final Constraint addConstraint;
|
||||
private final boolean dropDefault;
|
||||
private final boolean setNotNull;
|
||||
private final boolean dropNotNull;
|
||||
private final Constraint dropConstraint;
|
||||
private final boolean dropConstraintIfExists;
|
||||
private final Domain<?> renameTo;
|
||||
private final Constraint renameConstraint;
|
||||
private final boolean renameConstraintIfExists;
|
||||
private final Field<T> setDefault;
|
||||
private final Boolean cascade;
|
||||
private final Constraint renameConstraintTo;
|
||||
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 cascade;
|
||||
private Constraint renameConstraintTo;
|
||||
|
||||
AlterDomainImpl(
|
||||
Configuration configuration,
|
||||
@ -136,92 +136,47 @@ implements
|
||||
this.renameConstraintTo = renameConstraintTo;
|
||||
}
|
||||
|
||||
final Domain<T> $domain() { return domain; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
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 $cascade() { return cascade; }
|
||||
final Constraint $renameConstraintTo() { return renameConstraintTo; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> add(Constraint addConstraint) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.addConstraint = addConstraint;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropDefault() {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
true,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.dropDefault = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> setNotNull() {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
true,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.setNotNull = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropNotNull() {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
true,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.dropNotNull = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,23 +191,9 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropConstraint(Constraint dropConstraint) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
dropConstraint,
|
||||
false,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.dropConstraint = dropConstraint;
|
||||
this.dropConstraintIfExists = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -267,23 +208,9 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropConstraintIfExists(Constraint dropConstraint) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
dropConstraint,
|
||||
true,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.dropConstraint = dropConstraint;
|
||||
this.dropConstraintIfExists = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -298,23 +225,8 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> renameTo(Domain<?> renameTo) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.renameTo = renameTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -329,23 +241,9 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> renameConstraint(Constraint renameConstraint) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
renameConstraint,
|
||||
false,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.renameConstraint = renameConstraint;
|
||||
this.renameConstraintIfExists = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -360,23 +258,9 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> renameConstraintIfExists(Constraint renameConstraint) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
renameConstraint,
|
||||
true,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.renameConstraint = renameConstraint;
|
||||
this.renameConstraintIfExists = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -386,65 +270,20 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> setDefault(Field<T> setDefault) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
setDefault,
|
||||
this.cascade,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.setDefault = setDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> cascade() {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
true,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.cascade = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> restrict() {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
false,
|
||||
this.renameConstraintTo
|
||||
);
|
||||
this.cascade = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -459,23 +298,8 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> to(Constraint renameConstraintTo) {
|
||||
return new AlterDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
this.addConstraint,
|
||||
this.dropDefault,
|
||||
this.setNotNull,
|
||||
this.dropNotNull,
|
||||
this.dropConstraint,
|
||||
this.dropConstraintIfExists,
|
||||
this.renameTo,
|
||||
this.renameConstraint,
|
||||
this.renameConstraintIfExists,
|
||||
this.setDefault,
|
||||
this.cascade,
|
||||
renameConstraintTo
|
||||
);
|
||||
this.renameConstraintTo = renameConstraintTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -74,6 +74,9 @@ implements
|
||||
this.ifNotExists = ifNotExists;
|
||||
}
|
||||
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $ifNotExists() { return ifNotExists; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -64,9 +64,9 @@ implements
|
||||
|
||||
private final Domain<?> domain;
|
||||
private final boolean ifNotExists;
|
||||
private final DataType<T> dataType;
|
||||
private final Field<T> default_;
|
||||
private final Collection<? extends Constraint> constraints;
|
||||
private DataType<T> dataType;
|
||||
private Field<T> default_;
|
||||
private Collection<? extends Constraint> constraints;
|
||||
|
||||
CreateDomainImpl(
|
||||
Configuration configuration,
|
||||
@ -100,6 +100,12 @@ implements
|
||||
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; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
@ -111,14 +117,8 @@ implements
|
||||
|
||||
@Override
|
||||
public final <T> CreateDomainImpl<T> as(DataType<T> dataType) {
|
||||
return new CreateDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifNotExists,
|
||||
dataType,
|
||||
this.default_,
|
||||
this.constraints
|
||||
);
|
||||
this.dataType = (DataType) dataType;
|
||||
return (CreateDomainImpl) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,14 +128,8 @@ implements
|
||||
|
||||
@Override
|
||||
public final CreateDomainImpl<T> default_(Field<T> default_) {
|
||||
return new CreateDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifNotExists,
|
||||
this.dataType,
|
||||
default_,
|
||||
this.constraints
|
||||
);
|
||||
this.default_ = default_;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -145,14 +139,8 @@ implements
|
||||
|
||||
@Override
|
||||
public final CreateDomainImpl<T> constraints(Collection<? extends Constraint> constraints) {
|
||||
return new CreateDomainImpl<>(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifNotExists,
|
||||
this.dataType,
|
||||
this.default_,
|
||||
constraints
|
||||
);
|
||||
this.constraints = constraints;
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -37,59 +37,37 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.CREATE_SCHEMA;
|
||||
import static org.jooq.Clause.CREATE_SCHEMA_NAME;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.Keywords.K_CREATE;
|
||||
import static org.jooq.impl.Keywords.K_DATABASE;
|
||||
import static org.jooq.impl.Keywords.K_EXEC;
|
||||
import static org.jooq.impl.Keywords.K_IF_NOT_EXISTS;
|
||||
import static org.jooq.impl.Keywords.K_SCHEMA;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.Set;
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.CreateSchemaFinalStep;
|
||||
// ...
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Schema;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>CREATE SCHEMA IF NOT EXISTS</code> statement.
|
||||
*/
|
||||
final class CreateSchemaImpl extends AbstractRowCountQuery implements
|
||||
@SuppressWarnings({ "unused" })
|
||||
final class CreateSchemaImpl
|
||||
extends
|
||||
AbstractRowCountQuery
|
||||
implements
|
||||
CreateSchemaFinalStep
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Cascading interface implementations for CREATE SCHEMA behaviour
|
||||
CreateSchemaFinalStep {
|
||||
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 8904572826501186329L;
|
||||
private static final Clause[] CLAUSES = { CREATE_SCHEMA };
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = SQLDialect.supportedBy(DERBY, FIREBIRD);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final Schema schema;
|
||||
private final boolean ifNotExists;
|
||||
|
||||
CreateSchemaImpl(Configuration configuration, Schema schema, boolean ifNotExists) {
|
||||
private final Schema schema;
|
||||
private final boolean ifNotExists;
|
||||
|
||||
|
||||
CreateSchemaImpl(
|
||||
Configuration configuration,
|
||||
Schema schema,
|
||||
boolean ifNotExists
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.schema = schema;
|
||||
@ -99,13 +77,19 @@ final class CreateSchemaImpl extends AbstractRowCountQuery implements
|
||||
final Schema $schema() { return schema; }
|
||||
final boolean $ifNotExists() { return ifNotExists; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES = { Clause.CREATE_SCHEMA };
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = SQLDialect.supportedBy(DERBY, FIREBIRD);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final boolean supportsIfNotExists(Context<?> ctx) {
|
||||
return !NO_SUPPORT_IF_NOT_EXISTS.contains(ctx.family());
|
||||
@ -141,7 +125,7 @@ final class CreateSchemaImpl extends AbstractRowCountQuery implements
|
||||
}
|
||||
|
||||
private final void accept1(Context<?> ctx) {
|
||||
ctx.start(CREATE_SCHEMA_NAME)
|
||||
ctx.start(Clause.CREATE_SCHEMA_NAME)
|
||||
.visit(K_CREATE);
|
||||
|
||||
|
||||
@ -155,11 +139,13 @@ final class CreateSchemaImpl extends AbstractRowCountQuery implements
|
||||
ctx.sql(' ').visit(K_IF_NOT_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(schema)
|
||||
.end(CREATE_SCHEMA_NAME);
|
||||
.end(Clause.CREATE_SCHEMA_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -185,7 +185,6 @@ import org.jooq.ConstraintForeignKeyReferencesStepN;
|
||||
import org.jooq.ConstraintTypeStep;
|
||||
// ...
|
||||
import org.jooq.CreateIndexStep;
|
||||
import org.jooq.CreateSchemaFinalStep;
|
||||
import org.jooq.CreateSequenceFlagsStep;
|
||||
import org.jooq.CreateTableColumnStep;
|
||||
import org.jooq.CreateTypeStep;
|
||||
@ -6942,6 +6941,66 @@ public class DSL {
|
||||
return dsl().createDomainIfNotExists(domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchema(String)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.CreateSchemaFinalStep createSchema(String schema) {
|
||||
return dsl().createSchema(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchema(Name)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.CreateSchemaFinalStep createSchema(Name schema) {
|
||||
return dsl().createSchema(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchema(Schema)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.CreateSchemaFinalStep createSchema(Schema schema) {
|
||||
return dsl().createSchema(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA IF NOT EXISTS</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchemaIfNotExists(String)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.CreateSchemaFinalStep createSchemaIfNotExists(String schema) {
|
||||
return dsl().createSchemaIfNotExists(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA IF NOT EXISTS</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchemaIfNotExists(Name)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.CreateSchemaFinalStep createSchemaIfNotExists(Name schema) {
|
||||
return dsl().createSchemaIfNotExists(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA IF NOT EXISTS</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchemaIfNotExists(Schema)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.CreateSchemaFinalStep createSchemaIfNotExists(Schema schema) {
|
||||
return dsl().createSchemaIfNotExists(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ALTER DATABASE</code> statement.
|
||||
*
|
||||
@ -7184,66 +7243,6 @@ public class DSL {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchema(String)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static CreateSchemaFinalStep createSchema(String schema) {
|
||||
return dsl().createSchema(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchema(Name)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static CreateSchemaFinalStep createSchema(Name schema) {
|
||||
return dsl().createSchema(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchema(Schema)
|
||||
*/
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static CreateSchemaFinalStep createSchema(Schema schema) {
|
||||
return dsl().createSchema(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchemaIfNotExists(String)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
public static CreateSchemaFinalStep createSchemaIfNotExists(String schema) {
|
||||
return dsl().createSchemaIfNotExists(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchemaIfNotExists(Name)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
public static CreateSchemaFinalStep createSchemaIfNotExists(Name schema) {
|
||||
return dsl().createSchemaIfNotExists(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE SCHEMA</code> statement.
|
||||
*
|
||||
* @see DSLContext#createSchemaIfNotExists(Schema)
|
||||
*/
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES })
|
||||
public static CreateSchemaFinalStep createSchemaIfNotExists(Schema schema) {
|
||||
return dsl().createSchemaIfNotExists(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE TABLE</code> statement.
|
||||
*
|
||||
@ -10232,6 +10231,24 @@ public class DSL {
|
||||
return new CatalogImpl(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a qualified schema, given its schema name.
|
||||
* <p>
|
||||
* This constructs a schema reference given the schema's qualified name.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This schema...
|
||||
* schema(name("MY_CATALOG", "MY_SCHEMA"));
|
||||
*
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_CATALOG].[MY_SCHEMA]
|
||||
* </pre></code>
|
||||
*/
|
||||
@Support
|
||||
public static Schema schema(String name) {
|
||||
return schema(name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a qualified schema, given its schema name.
|
||||
* <p>
|
||||
|
||||
@ -115,7 +115,6 @@ import org.jooq.ConnectionRunnable;
|
||||
import org.jooq.ContextTransactionalCallable;
|
||||
import org.jooq.ContextTransactionalRunnable;
|
||||
import org.jooq.CreateIndexStep;
|
||||
import org.jooq.CreateSchemaFinalStep;
|
||||
import org.jooq.CreateSequenceFlagsStep;
|
||||
import org.jooq.CreateTableColumnStep;
|
||||
import org.jooq.CreateTypeStep;
|
||||
@ -2979,6 +2978,36 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
return new CreateDomainImpl<>(configuration(), domain, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchema(String schema) {
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(schema), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchema(Name schema) {
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(schema), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchema(Schema schema) {
|
||||
return new CreateSchemaImpl(configuration(), schema, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchemaIfNotExists(String schema) {
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(schema), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchemaIfNotExists(Name schema) {
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(schema), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchemaIfNotExists(Schema schema) {
|
||||
return new CreateSchemaImpl(configuration(), schema, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.AlterDatabaseStep alterDatabase(String database) {
|
||||
return new AlterDatabaseImpl(configuration(), DSL.catalog(database), false);
|
||||
@ -3396,36 +3425,6 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CreateSchemaFinalStep createSchema(String schema) {
|
||||
return createSchema(name(schema));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateSchemaFinalStep createSchema(Name schema) {
|
||||
return createSchema(schema(schema));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateSchemaFinalStep createSchema(Schema schema) {
|
||||
return new CreateSchemaImpl(configuration(), schema, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateSchemaFinalStep createSchemaIfNotExists(String schema) {
|
||||
return createSchemaIfNotExists(name(schema));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateSchemaFinalStep createSchemaIfNotExists(Name schema) {
|
||||
return createSchemaIfNotExists(schema(schema));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateSchemaFinalStep createSchemaIfNotExists(Schema schema) {
|
||||
return new CreateSchemaImpl(configuration(), schema, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateTableColumnStep createTable(String table) {
|
||||
return createTable(name(table));
|
||||
|
||||
@ -74,6 +74,9 @@ implements
|
||||
this.ifExists = ifExists;
|
||||
}
|
||||
|
||||
final Catalog $database() { return database; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -62,7 +62,7 @@ implements
|
||||
|
||||
private final Domain<?> domain;
|
||||
private final boolean ifExists;
|
||||
private final Boolean cascade;
|
||||
private Boolean cascade;
|
||||
|
||||
DropDomainImpl(
|
||||
Configuration configuration,
|
||||
@ -90,28 +90,24 @@ implements
|
||||
this.cascade = cascade;
|
||||
}
|
||||
|
||||
final Domain<?> $domain() { return domain; }
|
||||
final boolean $ifExists() { return ifExists; }
|
||||
final Boolean $cascade() { return cascade; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final DropDomainImpl cascade() {
|
||||
return new DropDomainImpl(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
true
|
||||
);
|
||||
this.cascade = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropDomainImpl restrict() {
|
||||
return new DropDomainImpl(
|
||||
configuration(),
|
||||
this.domain,
|
||||
this.ifExists,
|
||||
false
|
||||
);
|
||||
this.cascade = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user