[jOOQ/jOOQ#681] DOMAIN support
This change includes: - Support CREATE / ALTER / DROP DOMAIN in Firebird - Fix a regression in CREATE SEQUENCE
This commit is contained in:
parent
bcd7a2ab4f
commit
6b75127bba
@ -56,8 +56,8 @@ public class Keys {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
private static class Identities0 {
|
||||
public static Identity<AuthorRecord, Integer> IDENTITY_AUTHOR = Internal.createIdentity(Author.AUTHOR, Author.AUTHOR.ID);
|
||||
public static Identity<BookRecord, Integer> IDENTITY_BOOK = Internal.createIdentity(Book.BOOK, Book.BOOK.ID);
|
||||
static final Identity<AuthorRecord, Integer> IDENTITY_AUTHOR = Internal.createIdentity(Author.AUTHOR, Author.AUTHOR.ID);
|
||||
static final Identity<BookRecord, Integer> IDENTITY_BOOK = Internal.createIdentity(Book.BOOK, Book.BOOK.ID);
|
||||
}
|
||||
|
||||
private static class UniqueKeys0 {
|
||||
|
||||
@ -74,6 +74,6 @@ public interface AlterDomainDropConstraintCascadeStep extends AlterDomainFinalSt
|
||||
/**
|
||||
* Add the <code>RESTRICT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
AlterDomainFinalStep restrict();
|
||||
}
|
||||
|
||||
@ -68,61 +68,61 @@ public interface AlterDomainStep<T> {
|
||||
/**
|
||||
* Add the <code>ADD</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainFinalStep add(Constraint addConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP CONSTRAINT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainDropConstraintCascadeStep dropConstraint(String dropConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP CONSTRAINT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainDropConstraintCascadeStep dropConstraint(Name dropConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP CONSTRAINT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainDropConstraintCascadeStep dropConstraint(Constraint dropConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP CONSTRAINT IF EXISTS</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainDropConstraintCascadeStep dropConstraintIfExists(String dropConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP CONSTRAINT IF EXISTS</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainDropConstraintCascadeStep dropConstraintIfExists(Name dropConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP CONSTRAINT IF EXISTS</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainDropConstraintCascadeStep dropConstraintIfExists(Constraint dropConstraint);
|
||||
|
||||
/**
|
||||
* Add the <code>RENAME TO</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainFinalStep renameTo(String renameTo);
|
||||
|
||||
/**
|
||||
* Add the <code>RENAME TO</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainFinalStep renameTo(Name renameTo);
|
||||
|
||||
/**
|
||||
* Add the <code>RENAME TO</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainFinalStep renameTo(Domain<?> renameTo);
|
||||
|
||||
/**
|
||||
@ -164,19 +164,19 @@ public interface AlterDomainStep<T> {
|
||||
/**
|
||||
* Add the <code>SET DEFAULT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainFinalStep setDefault(T setDefault);
|
||||
|
||||
/**
|
||||
* Add the <code>SET DEFAULT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainFinalStep setDefault(Field<T> setDefault);
|
||||
|
||||
/**
|
||||
* Add the <code>DROP DEFAULT</code> clause to the <code>ALTER DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
AlterDomainFinalStep dropDefault();
|
||||
|
||||
/**
|
||||
|
||||
@ -68,12 +68,12 @@ public interface CreateDomainAsStep {
|
||||
/**
|
||||
* Add the <code>AS</code> clause to the <code>CREATE DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
<T> CreateDomainDefaultStep<T> as(Class<T> dataType);
|
||||
|
||||
/**
|
||||
* Add the <code>AS</code> clause to the <code>CREATE DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
<T> CreateDomainDefaultStep<T> as(DataType<T> dataType);
|
||||
}
|
||||
|
||||
@ -68,12 +68,12 @@ public interface CreateDomainConstraintStep extends CreateDomainFinalStep {
|
||||
/**
|
||||
* Add the <code>CONSTRAINTS</code> clause to the <code>CREATE DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainConstraintStep constraints(Constraint... constraints);
|
||||
|
||||
/**
|
||||
* Add the <code>CONSTRAINTS</code> clause to the <code>CREATE DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainConstraintStep constraints(Collection<? extends Constraint> constraints);
|
||||
}
|
||||
|
||||
@ -68,12 +68,12 @@ public interface CreateDomainDefaultStep<T> extends CreateDomainConstraintStep {
|
||||
/**
|
||||
* Add the <code>DEFAULT_</code> clause to the <code>CREATE DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainConstraintStep default_(T default_);
|
||||
|
||||
/**
|
||||
* Add the <code>DEFAULT_</code> clause to the <code>CREATE DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainConstraintStep default_(Field<T> default_);
|
||||
}
|
||||
|
||||
@ -8793,7 +8793,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#createDomain(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainAsStep createDomain(String domain);
|
||||
|
||||
/**
|
||||
@ -8801,7 +8801,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#createDomain(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainAsStep createDomain(Name domain);
|
||||
|
||||
/**
|
||||
@ -8809,7 +8809,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#createDomain(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainAsStep createDomain(Domain<?> domain);
|
||||
|
||||
/**
|
||||
@ -8817,7 +8817,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#createDomainIfNotExists(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainAsStep createDomainIfNotExists(String domain);
|
||||
|
||||
/**
|
||||
@ -8825,7 +8825,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#createDomainIfNotExists(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainAsStep createDomainIfNotExists(Name domain);
|
||||
|
||||
/**
|
||||
@ -8833,7 +8833,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#createDomainIfNotExists(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
CreateDomainAsStep createDomainIfNotExists(Domain<?> domain);
|
||||
|
||||
/**
|
||||
@ -8985,7 +8985,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#alterDomain(String)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
<T> AlterDomainStep<T> alterDomain(String domain);
|
||||
|
||||
/**
|
||||
@ -8993,7 +8993,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#alterDomain(Name)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
<T> AlterDomainStep<T> alterDomain(Name domain);
|
||||
|
||||
/**
|
||||
@ -9001,7 +9001,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#alterDomain(Domain)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
<T> AlterDomainStep<T> alterDomain(Domain<T> domain);
|
||||
|
||||
/**
|
||||
@ -9009,7 +9009,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#alterDomainIfExists(String)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
<T> AlterDomainStep<T> alterDomainIfExists(String domain);
|
||||
|
||||
/**
|
||||
@ -9017,7 +9017,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#alterDomainIfExists(Name)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
<T> AlterDomainStep<T> alterDomainIfExists(Name domain);
|
||||
|
||||
/**
|
||||
@ -9025,7 +9025,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#alterDomainIfExists(Domain)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
<T> AlterDomainStep<T> alterDomainIfExists(Domain<T> domain);
|
||||
|
||||
/**
|
||||
@ -9129,7 +9129,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#dropDomain(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
DropDomainCascadeStep dropDomain(String domain);
|
||||
|
||||
/**
|
||||
@ -9137,7 +9137,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#dropDomain(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
DropDomainCascadeStep dropDomain(Name domain);
|
||||
|
||||
/**
|
||||
@ -9145,7 +9145,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#dropDomain(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
DropDomainCascadeStep dropDomain(Domain<?> domain);
|
||||
|
||||
/**
|
||||
@ -9153,7 +9153,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#dropDomainIfExists(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
DropDomainCascadeStep dropDomainIfExists(String domain);
|
||||
|
||||
/**
|
||||
@ -9161,7 +9161,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#dropDomainIfExists(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
DropDomainCascadeStep dropDomainIfExists(Name domain);
|
||||
|
||||
/**
|
||||
@ -9169,7 +9169,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*
|
||||
* @see DSL#dropDomainIfExists(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
DropDomainCascadeStep dropDomainIfExists(Domain<?> domain);
|
||||
|
||||
/**
|
||||
|
||||
@ -74,6 +74,6 @@ public interface DropDomainCascadeStep extends DropDomainFinalStep {
|
||||
/**
|
||||
* Add the <code>RESTRICT</code> clause to the <code>DROP DOMAIN</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
DropDomainFinalStep restrict();
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDatabaseImpl renameTo(String renameTo) {
|
||||
return renameTo(DSL.catalog(renameTo));
|
||||
return renameTo(DSL.catalog(DSL.name(renameTo)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,14 +37,39 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.impl.DSL.check;
|
||||
import static org.jooq.impl.Keywords.K_ADD;
|
||||
import static org.jooq.impl.Keywords.K_ALTER;
|
||||
import static org.jooq.impl.Keywords.K_CASCADE;
|
||||
import static org.jooq.impl.Keywords.K_DOMAIN;
|
||||
import static org.jooq.impl.Keywords.K_DROP_CONSTRAINT;
|
||||
import static org.jooq.impl.Keywords.K_DROP_DEFAULT;
|
||||
import static org.jooq.impl.Keywords.K_DROP_NOT_NULL;
|
||||
import static org.jooq.impl.Keywords.K_IF_EXISTS;
|
||||
import static org.jooq.impl.Keywords.K_RENAME_CONSTRAINT;
|
||||
import static org.jooq.impl.Keywords.K_RENAME_TO;
|
||||
import static org.jooq.impl.Keywords.K_RESTRICT;
|
||||
import static org.jooq.impl.Keywords.K_SET_DEFAULT;
|
||||
import static org.jooq.impl.Keywords.K_SET_NOT_NULL;
|
||||
import static org.jooq.impl.Keywords.K_TO;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_CONSTRAINT_REFERENCE;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.*;
|
||||
import org.jooq.AlterDomainDropConstraintCascadeStep;
|
||||
import org.jooq.AlterDomainFinalStep;
|
||||
import org.jooq.AlterDomainRenameConstraintStep;
|
||||
import org.jooq.AlterDomainStep;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Constraint;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Domain;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.SQLDialect;
|
||||
|
||||
/**
|
||||
* The <code>ALTER DOMAIN IF EXISTS</code> statement.
|
||||
@ -76,7 +101,7 @@ implements
|
||||
private boolean dropNotNull;
|
||||
private Boolean cascade;
|
||||
private Constraint renameConstraintTo;
|
||||
|
||||
|
||||
AlterDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
@ -154,7 +179,7 @@ implements
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> add(Constraint addConstraint) {
|
||||
this.addConstraint = addConstraint;
|
||||
@ -163,7 +188,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropConstraint(String dropConstraint) {
|
||||
return dropConstraint(DSL.constraint(dropConstraint));
|
||||
return dropConstraint(DSL.constraint(DSL.name(dropConstraint)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -180,7 +205,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> dropConstraintIfExists(String dropConstraint) {
|
||||
return dropConstraintIfExists(DSL.constraint(dropConstraint));
|
||||
return dropConstraintIfExists(DSL.constraint(DSL.name(dropConstraint)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -197,7 +222,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> renameTo(String renameTo) {
|
||||
return renameTo(DSL.domain(renameTo));
|
||||
return renameTo(DSL.domain(DSL.name(renameTo)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -213,7 +238,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> renameConstraint(String renameConstraint) {
|
||||
return renameConstraint(DSL.constraint(renameConstraint));
|
||||
return renameConstraint(DSL.constraint(DSL.name(renameConstraint)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -230,7 +255,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> renameConstraintIfExists(String renameConstraint) {
|
||||
return renameConstraintIfExists(DSL.constraint(renameConstraint));
|
||||
return renameConstraintIfExists(DSL.constraint(DSL.name(renameConstraint)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -288,7 +313,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> to(String renameConstraintTo) {
|
||||
return to(DSL.constraint(renameConstraintTo));
|
||||
return to(DSL.constraint(DSL.name(renameConstraintTo)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -308,12 +333,17 @@ implements
|
||||
|
||||
|
||||
|
||||
private static final Set<SQLDialect> NO_SUPPORT_RENAME_CONSTRAINT_IF_EXISTS = SQLDialect.supportedBy(POSTGRES);
|
||||
private static final Set<SQLDialect> NO_SUPPORT_RENAME_CONSTRAINT_IF_EXISTS = SQLDialect.supportedBy(FIREBIRD, POSTGRES);
|
||||
private static final Set<SQLDialect> NO_SUPPORT_DROP_CONSTRAINT_IF_EXISTS = SQLDialect.supportedBy(FIREBIRD, POSTGRES);
|
||||
|
||||
private final boolean supportsRenameConstraintIfExists(Context<?> ctx) {
|
||||
return !NO_SUPPORT_RENAME_CONSTRAINT_IF_EXISTS.contains(ctx.family());
|
||||
}
|
||||
|
||||
private final boolean supportsDropConstraintIfExists(Context<?> ctx) {
|
||||
return !NO_SUPPORT_DROP_CONSTRAINT_IF_EXISTS.contains(ctx.family());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (renameConstraintIfExists && !supportsRenameConstraintIfExists(ctx)) {
|
||||
@ -336,27 +366,32 @@ implements
|
||||
ctx.visit(domain).sql(' ');
|
||||
|
||||
if (addConstraint != null) {
|
||||
ctx.visit(K_ADD).sql(' ').visit(addConstraint);
|
||||
if (ctx.family() == FIREBIRD)
|
||||
ctx.visit(K_ADD).sql(' ').visit(check(((ConstraintImpl) addConstraint).$check()));
|
||||
else
|
||||
ctx.visit(K_ADD).sql(' ').visit(addConstraint);
|
||||
}
|
||||
else if (dropConstraint != null) {
|
||||
ctx.visit(K_DROP_CONSTRAINT).sql(' ');
|
||||
ctx.visit(K_DROP_CONSTRAINT);
|
||||
|
||||
if (dropConstraintIfExists)
|
||||
ctx.visit(K_IF_EXISTS).sql(' ');
|
||||
if (dropConstraintIfExists && supportsDropConstraintIfExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_EXISTS);
|
||||
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, true);
|
||||
ctx.visit(dropConstraint);
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, previous);
|
||||
if (ctx.family() != FIREBIRD) {
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, true);
|
||||
ctx.sql(' ').visit(dropConstraint);
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, previous);
|
||||
|
||||
if (cascade != null)
|
||||
if (cascade)
|
||||
ctx.sql(' ').visit(K_CASCADE);
|
||||
else
|
||||
ctx.sql(' ').visit(K_RESTRICT);
|
||||
if (cascade != null)
|
||||
if (cascade)
|
||||
ctx.sql(' ').visit(K_CASCADE);
|
||||
else
|
||||
ctx.sql(' ').visit(K_RESTRICT);
|
||||
}
|
||||
}
|
||||
else if (renameTo != null) {
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, true);
|
||||
ctx.visit(K_RENAME_TO).sql(' ').visit(renameTo);
|
||||
ctx.visit(ctx.family() == FIREBIRD ? K_TO : K_RENAME_TO).sql(' ').visit(renameTo);
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, previous);
|
||||
}
|
||||
else if (renameConstraint != null) {
|
||||
|
||||
@ -100,7 +100,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final AlterSchemaImpl renameTo(String renameTo) {
|
||||
return renameTo(DSL.schema(renameTo));
|
||||
return renameTo(DSL.schema(DSL.name(renameTo)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,14 +37,38 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.and;
|
||||
import static org.jooq.impl.DSL.check;
|
||||
import static org.jooq.impl.Keywords.K_AS;
|
||||
import static org.jooq.impl.Keywords.K_CREATE;
|
||||
import static org.jooq.impl.Keywords.K_DEFAULT;
|
||||
import static org.jooq.impl.Keywords.K_DOMAIN;
|
||||
import static org.jooq.impl.Keywords.K_FROM;
|
||||
import static org.jooq.impl.Keywords.K_IF_NOT_EXISTS;
|
||||
import static org.jooq.impl.Keywords.K_TYPE;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.*;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Constraint;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.CreateDomainAsStep;
|
||||
import org.jooq.CreateDomainConstraintStep;
|
||||
import org.jooq.CreateDomainDefaultStep;
|
||||
import org.jooq.CreateDomainFinalStep;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Domain;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.SQLDialect;
|
||||
|
||||
/**
|
||||
* The <code>CREATE DOMAIN IF NOT EXISTS</code> statement.
|
||||
@ -67,7 +91,7 @@ implements
|
||||
private DataType<T> dataType;
|
||||
private Field<T> default_;
|
||||
private Collection<? extends Constraint> constraints;
|
||||
|
||||
|
||||
CreateDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
@ -109,7 +133,7 @@ implements
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final <T> CreateDomainImpl<T> as(Class<T> dataType) {
|
||||
return as(DefaultDataType.getDataType(null, dataType));
|
||||
@ -149,7 +173,7 @@ implements
|
||||
|
||||
|
||||
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = SQLDialect.supportedBy(POSTGRES);
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = SQLDialect.supportedBy(FIREBIRD, POSTGRES);
|
||||
|
||||
private final boolean supportsIfNotExists(Context<?> ctx) {
|
||||
return !NO_SUPPORT_IF_NOT_EXISTS.contains(ctx.family());
|
||||
@ -187,9 +211,20 @@ implements
|
||||
if (default_ != null)
|
||||
ctx.formatSeparator().visit(K_DEFAULT).sql(' ').visit(default_);
|
||||
|
||||
if (constraints != null)
|
||||
for (Constraint constraint : constraints)
|
||||
ctx.formatSeparator().visit(constraint);
|
||||
if (constraints != null) {
|
||||
if (ctx.family() == FIREBIRD) {
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
|
||||
for (Constraint constraint : constraints)
|
||||
conditions.add(((ConstraintImpl) constraint).$check());
|
||||
|
||||
ctx.formatSeparator().visit(check(and(conditions)));
|
||||
}
|
||||
else {
|
||||
for (Constraint constraint : constraints)
|
||||
ctx.formatSeparator().visit(constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6882,7 +6882,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#createDomain(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.CreateDomainAsStep createDomain(String domain) {
|
||||
return dsl().createDomain(domain);
|
||||
}
|
||||
@ -6892,7 +6892,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#createDomain(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.CreateDomainAsStep createDomain(Name domain) {
|
||||
return dsl().createDomain(domain);
|
||||
}
|
||||
@ -6902,7 +6902,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#createDomain(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.CreateDomainAsStep createDomain(Domain<?> domain) {
|
||||
return dsl().createDomain(domain);
|
||||
}
|
||||
@ -6912,7 +6912,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#createDomainIfNotExists(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.CreateDomainAsStep createDomainIfNotExists(String domain) {
|
||||
return dsl().createDomainIfNotExists(domain);
|
||||
}
|
||||
@ -6922,7 +6922,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#createDomainIfNotExists(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.CreateDomainAsStep createDomainIfNotExists(Name domain) {
|
||||
return dsl().createDomainIfNotExists(domain);
|
||||
}
|
||||
@ -6932,7 +6932,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#createDomainIfNotExists(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.CreateDomainAsStep createDomainIfNotExists(Domain<?> domain) {
|
||||
return dsl().createDomainIfNotExists(domain);
|
||||
}
|
||||
@ -7122,7 +7122,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#alterDomain(String)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
public static <T> org.jooq.AlterDomainStep<T> alterDomain(String domain) {
|
||||
return dsl().alterDomain(domain);
|
||||
}
|
||||
@ -7132,7 +7132,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#alterDomain(Name)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
public static <T> org.jooq.AlterDomainStep<T> alterDomain(Name domain) {
|
||||
return dsl().alterDomain(domain);
|
||||
}
|
||||
@ -7142,7 +7142,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#alterDomain(Domain)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
public static <T> org.jooq.AlterDomainStep<T> alterDomain(Domain<T> domain) {
|
||||
return dsl().alterDomain(domain);
|
||||
}
|
||||
@ -7152,7 +7152,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#alterDomainIfExists(String)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
public static <T> org.jooq.AlterDomainStep<T> alterDomainIfExists(String domain) {
|
||||
return dsl().alterDomainIfExists(domain);
|
||||
}
|
||||
@ -7162,7 +7162,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#alterDomainIfExists(Name)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
public static <T> org.jooq.AlterDomainStep<T> alterDomainIfExists(Name domain) {
|
||||
return dsl().alterDomainIfExists(domain);
|
||||
}
|
||||
@ -7172,7 +7172,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#alterDomainIfExists(Domain)
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
public static <T> org.jooq.AlterDomainStep<T> alterDomainIfExists(Domain<T> domain) {
|
||||
return dsl().alterDomainIfExists(domain);
|
||||
}
|
||||
@ -7302,7 +7302,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#dropDomain(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.DropDomainCascadeStep dropDomain(String domain) {
|
||||
return dsl().dropDomain(domain);
|
||||
}
|
||||
@ -7312,7 +7312,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#dropDomain(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.DropDomainCascadeStep dropDomain(Name domain) {
|
||||
return dsl().dropDomain(domain);
|
||||
}
|
||||
@ -7322,7 +7322,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#dropDomain(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.DropDomainCascadeStep dropDomain(Domain<?> domain) {
|
||||
return dsl().dropDomain(domain);
|
||||
}
|
||||
@ -7332,7 +7332,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#dropDomainIfExists(String)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.DropDomainCascadeStep dropDomainIfExists(String domain) {
|
||||
return dsl().dropDomainIfExists(domain);
|
||||
}
|
||||
@ -7342,7 +7342,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#dropDomainIfExists(Name)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.DropDomainCascadeStep dropDomainIfExists(Name domain) {
|
||||
return dsl().dropDomainIfExists(domain);
|
||||
}
|
||||
@ -7352,7 +7352,7 @@ public class DSL {
|
||||
*
|
||||
* @see DSLContext#dropDomainIfExists(Domain)
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static org.jooq.DropDomainCascadeStep dropDomainIfExists(Domain<?> domain) {
|
||||
return dsl().dropDomainIfExists(domain);
|
||||
}
|
||||
@ -11931,7 +11931,7 @@ public class DSL {
|
||||
* Create the <code>VALUE</code> pseudo field for usage with
|
||||
* <code>DOMAIN</code> specifications.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static <T> Field<T> value(Class<T> type) {
|
||||
return value(DefaultDataType.getDataType(null, type));
|
||||
}
|
||||
@ -11940,7 +11940,7 @@ public class DSL {
|
||||
* Create the <code>VALUE</code> pseudo field for usage with
|
||||
* <code>DOMAIN</code> specifications.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static <T> Field<T> value(DataType<T> type) {
|
||||
return field("{0}", type, N_VALUE);
|
||||
}
|
||||
@ -11948,7 +11948,7 @@ public class DSL {
|
||||
/**
|
||||
* Create a <code>DOMAIN</code> reference.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static Domain<?> domain(String name) {
|
||||
return domain(name(name));
|
||||
}
|
||||
@ -11956,7 +11956,7 @@ public class DSL {
|
||||
/**
|
||||
* Create a <code>DOMAIN</code> reference.
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
@Support({ FIREBIRD, H2, POSTGRES })
|
||||
public static Domain<?> domain(Name name) {
|
||||
return new DomainImpl<>(null, name, new DefaultDataType<>(null, Object.class, name));
|
||||
}
|
||||
|
||||
@ -2916,7 +2916,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateDatabaseFinalStep createDatabase(String database) {
|
||||
return new CreateDatabaseImpl(configuration(), DSL.catalog(database), false);
|
||||
return new CreateDatabaseImpl(configuration(), DSL.catalog(DSL.name(database)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2931,7 +2931,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateDatabaseFinalStep createDatabaseIfNotExists(String database) {
|
||||
return new CreateDatabaseImpl(configuration(), DSL.catalog(database), true);
|
||||
return new CreateDatabaseImpl(configuration(), DSL.catalog(DSL.name(database)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2946,7 +2946,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateDomainAsStep createDomain(String domain) {
|
||||
return new CreateDomainImpl<>(configuration(), DSL.domain(domain), false);
|
||||
return new CreateDomainImpl<>(configuration(), DSL.domain(DSL.name(domain)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2961,7 +2961,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateDomainAsStep createDomainIfNotExists(String domain) {
|
||||
return new CreateDomainImpl<>(configuration(), DSL.domain(domain), true);
|
||||
return new CreateDomainImpl<>(configuration(), DSL.domain(DSL.name(domain)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2976,7 +2976,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchema(String schema) {
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(schema), false);
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2991,7 +2991,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchemaIfNotExists(String schema) {
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(schema), true);
|
||||
return new CreateSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3006,7 +3006,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSequenceFlagsStep createSequence(String sequence) {
|
||||
return new CreateSequenceImpl(configuration(), DSL.sequence(sequence), false);
|
||||
return new CreateSequenceImpl(configuration(), DSL.sequence(DSL.name(sequence)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3021,7 +3021,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSequenceFlagsStep createSequenceIfNotExists(String sequence) {
|
||||
return new CreateSequenceImpl(configuration(), DSL.sequence(sequence), true);
|
||||
return new CreateSequenceImpl(configuration(), DSL.sequence(DSL.name(sequence)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3036,7 +3036,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.AlterDatabaseStep alterDatabase(String database) {
|
||||
return new AlterDatabaseImpl(configuration(), DSL.catalog(database), false);
|
||||
return new AlterDatabaseImpl(configuration(), DSL.catalog(DSL.name(database)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3051,7 +3051,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.AlterDatabaseStep alterDatabaseIfExists(String database) {
|
||||
return new AlterDatabaseImpl(configuration(), DSL.catalog(database), true);
|
||||
return new AlterDatabaseImpl(configuration(), DSL.catalog(DSL.name(database)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3066,7 +3066,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public <T> org.jooq.AlterDomainStep<T> alterDomain(String domain) {
|
||||
return new AlterDomainImpl<>(configuration(), DSL.domain(domain), false);
|
||||
return new AlterDomainImpl<>(configuration(), DSL.domain(DSL.name(domain)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3081,7 +3081,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public <T> org.jooq.AlterDomainStep<T> alterDomainIfExists(String domain) {
|
||||
return new AlterDomainImpl<>(configuration(), DSL.domain(domain), true);
|
||||
return new AlterDomainImpl<>(configuration(), DSL.domain(DSL.name(domain)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3096,7 +3096,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.AlterSchemaStep alterSchema(String schema) {
|
||||
return new AlterSchemaImpl(configuration(), DSL.schema(schema), false);
|
||||
return new AlterSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3111,7 +3111,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.AlterSchemaStep alterSchemaIfExists(String schema) {
|
||||
return new AlterSchemaImpl(configuration(), DSL.schema(schema), true);
|
||||
return new AlterSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3126,7 +3126,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropDatabaseFinalStep dropDatabase(String database) {
|
||||
return new DropDatabaseImpl(configuration(), DSL.catalog(database), false);
|
||||
return new DropDatabaseImpl(configuration(), DSL.catalog(DSL.name(database)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3141,7 +3141,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropDatabaseFinalStep dropDatabaseIfExists(String database) {
|
||||
return new DropDatabaseImpl(configuration(), DSL.catalog(database), true);
|
||||
return new DropDatabaseImpl(configuration(), DSL.catalog(DSL.name(database)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3156,7 +3156,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropDomainCascadeStep dropDomain(String domain) {
|
||||
return new DropDomainImpl(configuration(), DSL.domain(domain), false);
|
||||
return new DropDomainImpl(configuration(), DSL.domain(DSL.name(domain)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3171,7 +3171,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropDomainCascadeStep dropDomainIfExists(String domain) {
|
||||
return new DropDomainImpl(configuration(), DSL.domain(domain), true);
|
||||
return new DropDomainImpl(configuration(), DSL.domain(DSL.name(domain)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3186,7 +3186,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropSchemaStep dropSchema(String schema) {
|
||||
return new DropSchemaImpl(configuration(), DSL.schema(schema), false);
|
||||
return new DropSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3201,7 +3201,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropSchemaStep dropSchemaIfExists(String schema) {
|
||||
return new DropSchemaImpl(configuration(), DSL.schema(schema), true);
|
||||
return new DropSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3216,7 +3216,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropSequenceFinalStep dropSequence(String sequence) {
|
||||
return new DropSequenceImpl(configuration(), DSL.sequence(sequence), false);
|
||||
return new DropSequenceImpl(configuration(), DSL.sequence(DSL.name(sequence)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3231,7 +3231,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
@Override
|
||||
public org.jooq.DropSequenceFinalStep dropSequenceIfExists(String sequence) {
|
||||
return new DropSequenceImpl(configuration(), DSL.sequence(sequence), true);
|
||||
return new DropSequenceImpl(configuration(), DSL.sequence(DSL.name(sequence)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,14 +37,22 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.impl.Keywords.K_CASCADE;
|
||||
import static org.jooq.impl.Keywords.K_DOMAIN;
|
||||
import static org.jooq.impl.Keywords.K_DROP;
|
||||
import static org.jooq.impl.Keywords.K_IF_EXISTS;
|
||||
import static org.jooq.impl.Keywords.K_RESTRICT;
|
||||
import static org.jooq.impl.Keywords.K_TYPE;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.*;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Domain;
|
||||
import org.jooq.DropDomainCascadeStep;
|
||||
import org.jooq.DropDomainFinalStep;
|
||||
import org.jooq.SQLDialect;
|
||||
|
||||
/**
|
||||
* The <code>DROP DOMAIN IF EXISTS</code> statement.
|
||||
@ -63,7 +71,7 @@ implements
|
||||
private final Domain<?> domain;
|
||||
private final boolean dropDomainIfExists;
|
||||
private Boolean cascade;
|
||||
|
||||
|
||||
DropDomainImpl(
|
||||
Configuration configuration,
|
||||
Domain domain,
|
||||
@ -97,7 +105,7 @@ implements
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final DropDomainImpl cascade() {
|
||||
this.cascade = true;
|
||||
@ -116,8 +124,24 @@ implements
|
||||
|
||||
|
||||
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_EXISTS = SQLDialect.supportedBy(FIREBIRD);
|
||||
|
||||
private final boolean supportsIfExists(Context<?> ctx) {
|
||||
return !NO_SUPPORT_IF_EXISTS.contains(ctx.family());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (dropDomainIfExists && !supportsIfExists(ctx)) {
|
||||
Tools.beginTryCatch(ctx, DDLStatementType.DROP_DOMAIN);
|
||||
accept0(ctx);
|
||||
Tools.endTryCatch(ctx, DDLStatementType.DROP_DOMAIN);
|
||||
}
|
||||
else
|
||||
accept0(ctx);
|
||||
}
|
||||
|
||||
private final void accept0(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
@ -130,7 +154,7 @@ implements
|
||||
break;
|
||||
}
|
||||
|
||||
if (dropDomainIfExists)
|
||||
if (dropDomainIfExists && supportsIfExists(ctx))
|
||||
ctx.sql(' ').visit(K_IF_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(domain);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user