[jOOQ/jOOQ#15516] Add a new org.jooq.Type<T> API, a meta model for user defined types, to be used also in DDL
This is a prerequisite for [jOOQ/jOOQ#8474]
This commit is contained in:
parent
19a8c23759
commit
18f5e7164f
@ -37,9 +37,19 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
/**
|
||||
* A {@link Query} that can create types.
|
||||
* A step in the construction of the <code>CREATE TYPE</code> statement.
|
||||
* <p>
|
||||
* @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -58,11 +68,8 @@ package org.jooq;
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*
|
||||
* @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
@Deprecated(forRemoval = true, since = "3.15")
|
||||
public interface CreateTypeFinalStep extends DDLQuery {
|
||||
|
||||
}
|
||||
|
||||
@ -37,17 +37,17 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A {@link Query} that can create types.
|
||||
* A step in the construction of the <code>CREATE TYPE</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -66,37 +66,35 @@ import java.util.Collection;
|
||||
* <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 CreateTypeStep {
|
||||
|
||||
/**
|
||||
* Add the <code>AS ENUM</code> clause to the <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeFinalStep asEnum();
|
||||
|
||||
/**
|
||||
* Add the <code>AS ENUM</code> clause to the <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeFinalStep asEnum(String... values);
|
||||
|
||||
/**
|
||||
* Add the <code>AS ENUM</code> clause to the <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
@NotNull @CheckReturnValue
|
||||
CreateTypeFinalStep asEnum(Field<String>... values);
|
||||
|
||||
/**
|
||||
* Add the <code>AS ENUM</code> clause to the <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeFinalStep asEnum(Collection<?> values);
|
||||
@NotNull @CheckReturnValue
|
||||
CreateTypeFinalStep asEnum(Collection<? extends Field<String>> values);
|
||||
|
||||
/**
|
||||
* Add the <code>AS ENUM</code> clause to the <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
@NotNull @CheckReturnValue
|
||||
CreateTypeFinalStep asEnum();
|
||||
}
|
||||
|
||||
@ -10273,6 +10273,33 @@ public interface DSLContext extends Scope {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#createType(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeStep createType(@Stringly.Name String type);
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#createType(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeStep createType(Name type);
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#createType(Type)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeStep createType(Type<?> type);
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
@ -10891,6 +10918,132 @@ public interface DSLContext extends Scope {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(@Stringly.Name String types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Name types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Type)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Type<?> types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(String...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(String... types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Name...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Name... types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Type...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Type<?>... types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Collection)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Collection<? extends Type<?>> types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(@Stringly.Name String types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Name types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Type)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Type<?> types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(String...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(String... types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Name...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Name... types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Type...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Type<?>... types);
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Collection)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Collection<? extends Type<?>> types);
|
||||
|
||||
/**
|
||||
* The <code>DROP VIEW</code> statement.
|
||||
@ -11725,114 +11878,6 @@ public interface DSLContext extends Scope {
|
||||
@Support({ DUCKDB, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
CreateViewAsStep<Record> createViewIfNotExists(Table<?> view, BiFunction<? super Field<?>, ? super Integer, ? extends Field<?>> fieldNameFunction);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#createType(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeStep createType(String type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#createType(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
CreateTypeStep createType(Name type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(String type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Name type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(String...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(String... type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Name...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Name... type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Collection)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropType(Collection<?> type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(String type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Name type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(String...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(String... type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Name...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Name... type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Collection)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
DropTypeStep dropTypeIfExists(Collection<?> type);
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>ALTER TABLE</code> statement.
|
||||
*
|
||||
|
||||
@ -37,9 +37,19 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
/**
|
||||
* A {@link Query} that can drop types.
|
||||
* A step in the construction of the <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -58,11 +68,8 @@ package org.jooq;
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*
|
||||
* @deprecated - [#11329] - 3.15.0 - This type will be removed in the future. Do not reference it directly
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
@Deprecated(forRemoval = true, since = "3.15")
|
||||
public interface DropTypeFinalStep extends DDLQuery {
|
||||
|
||||
}
|
||||
|
||||
@ -37,15 +37,17 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
/**
|
||||
* A {@link Query} that can drop types.
|
||||
* A step in the construction of the <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
@ -64,22 +66,21 @@ import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
* <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 DropTypeStep extends DropTypeFinalStep {
|
||||
|
||||
/**
|
||||
* Add the <code>CASCADE</code> clause to the <code>DROP TYPE</code> statement.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
@NotNull @CheckReturnValue
|
||||
DropTypeFinalStep cascade();
|
||||
|
||||
/**
|
||||
* Add the <code>RESTRICT</code> clause to the <code>DROP TYPE</code> statement.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
@NotNull @CheckReturnValue
|
||||
DropTypeFinalStep restrict();
|
||||
}
|
||||
|
||||
47
jOOQ/src/main/java/org/jooq/Type.java
Normal file
47
jOOQ/src/main/java/org/jooq/Type.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: https://www.jooq.org/legal/licensing
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* An object representing a user defined type.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface Type<T> extends Typed<T> {
|
||||
|
||||
}
|
||||
@ -37,83 +37,98 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Keywords.K_AS;
|
||||
import static org.jooq.impl.Keywords.K_CREATE;
|
||||
import static org.jooq.impl.Keywords.K_ENUM;
|
||||
import static org.jooq.impl.Keywords.K_TYPE;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.impl.Tools.ExtendedDataKey.*;
|
||||
import static org.jooq.impl.Tools.SimpleDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.CreateTypeFinalStep;
|
||||
import org.jooq.CreateTypeStep;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.*;
|
||||
import org.jooq.Function1;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.conf.ParamType;
|
||||
import org.jooq.impl.QOM.CreateType;
|
||||
import org.jooq.impl.QOM.UnmodifiableList;
|
||||
import org.jooq.QueryPart;
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.Record;
|
||||
import org.jooq.conf.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
final class CreateTypeImpl extends AbstractDDLQuery implements
|
||||
|
||||
// Cascading interface implementations for CREATE TYPE behaviour
|
||||
@SuppressWarnings({ "hiding", "rawtypes", "unused" })
|
||||
final class CreateTypeImpl
|
||||
extends
|
||||
AbstractDDLQuery
|
||||
implements
|
||||
QOM.CreateType,
|
||||
CreateTypeStep,
|
||||
CreateTypeFinalStep,
|
||||
CreateType
|
||||
|
||||
CreateTypeFinalStep
|
||||
{
|
||||
|
||||
private final Name type;
|
||||
private final QueryPartList<Field<String>> values;
|
||||
final Type<?> type;
|
||||
QueryPartListView<? extends Field<String>> values;
|
||||
|
||||
CreateTypeImpl(Configuration configuration, Name type) {
|
||||
CreateTypeImpl(
|
||||
Configuration configuration,
|
||||
Type<?> type
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
type,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
CreateTypeImpl(
|
||||
Configuration configuration,
|
||||
Type<?> type,
|
||||
Collection<? extends Field<String>> values
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.type = type;
|
||||
this.values = new QueryPartList<>();
|
||||
this.values = new QueryPartList<>(values);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final CreateTypeFinalStep asEnum() {
|
||||
return asEnum(Collections.emptyList());
|
||||
public final CreateTypeImpl asEnum(String... values) {
|
||||
return asEnum(Tools.fields(values));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CreateTypeFinalStep asEnum(String... v) {
|
||||
return asEnum(Tools.map(v, s -> DSL.inline(s)));
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
@Override
|
||||
public final CreateTypeFinalStep asEnum(Field<String>... v) {
|
||||
return asEnum(Arrays.asList(v));
|
||||
public final CreateTypeImpl asEnum(Field<String>... values) {
|
||||
return asEnum(Arrays.asList(values));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CreateTypeFinalStep asEnum(Collection<?> v) {
|
||||
values.addAll(Tools.fields(v, VARCHAR));
|
||||
public final CreateTypeImpl asEnum(Collection<? extends Field<String>> values) {
|
||||
this.values = new QueryPartList<>(values);
|
||||
return this;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@Override
|
||||
public final CreateTypeImpl asEnum() {
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
@ -124,12 +139,14 @@ final class CreateTypeImpl extends AbstractDDLQuery implements
|
||||
.sql(')');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Name $name() {
|
||||
public final Type<?> $type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -138,6 +155,29 @@ final class CreateTypeImpl extends AbstractDDLQuery implements
|
||||
return QOM.unmodifiable(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.CreateType $type(Type<?> newValue) {
|
||||
return $constructor().apply(newValue, $values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.CreateType $values(Collection<? extends Field<String>> newValue) {
|
||||
return $constructor().apply($type(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Type<?>, ? super Collection<? extends Field<String>>, ? extends QOM.CreateType> $constructor() {
|
||||
return (a1, a2) -> new CreateTypeImpl(configuration(), a1, (Collection<? extends Field<String>>) a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -389,6 +389,7 @@ import org.jooq.Support;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableLike;
|
||||
import org.jooq.True;
|
||||
import org.jooq.Type;
|
||||
import org.jooq.Update;
|
||||
import org.jooq.UpdateSetFirstStep;
|
||||
import org.jooq.User;
|
||||
@ -8767,6 +8768,51 @@ public class DSL {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#createType(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.CreateTypeStep createType(@Stringly.Name String type) {
|
||||
return dsl().createType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#createType(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.CreateTypeStep createType(Name type) {
|
||||
return dsl().createType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#createType(Type)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.CreateTypeStep createType(Type<?> type) {
|
||||
return dsl().createType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
@ -9781,6 +9827,216 @@ public class DSL {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropType(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropType(@Stringly.Name String types) {
|
||||
return dsl().dropType(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropType(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropType(Name types) {
|
||||
return dsl().dropType(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropType(Type)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropType(Type<?> types) {
|
||||
return dsl().dropType(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropType(String...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropType(String... types) {
|
||||
return dsl().dropType(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropType(Name...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropType(Name... types) {
|
||||
return dsl().dropType(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropType(Type...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropType(Type<?>... types) {
|
||||
return dsl().dropType(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropType(Collection)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropType(Collection<? extends Type<?>> types) {
|
||||
return dsl().dropType(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropTypeIfExists(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropTypeIfExists(@Stringly.Name String types) {
|
||||
return dsl().dropTypeIfExists(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropTypeIfExists(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropTypeIfExists(Name types) {
|
||||
return dsl().dropTypeIfExists(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropTypeIfExists(Type)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropTypeIfExists(Type<?> types) {
|
||||
return dsl().dropTypeIfExists(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropTypeIfExists(String...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropTypeIfExists(String... types) {
|
||||
return dsl().dropTypeIfExists(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropTypeIfExists(Name...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropTypeIfExists(Name... types) {
|
||||
return dsl().dropTypeIfExists(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropTypeIfExists(Type...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropTypeIfExists(Type<?>... types) {
|
||||
return dsl().dropTypeIfExists(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE IF EXISTS</code> statement.
|
||||
* <p>
|
||||
* Unlike statement construction methods in the {@link DSLContext} API, this
|
||||
* creates an unattached, and thus not directly renderable or executable
|
||||
* statement. It can be used as a subquery or nested in procedural logic.
|
||||
*
|
||||
* @see DSLContext#dropTypeIfExists(Collection)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.DropTypeStep dropTypeIfExists(Collection<? extends Type<?>> types) {
|
||||
return dsl().dropTypeIfExists(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP VIEW</code> statement.
|
||||
@ -10720,138 +10976,6 @@ public class DSL {
|
||||
return dsl().createViewIfNotExists(view, fieldNameFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* @see DSLContext#createType(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static CreateTypeStep createType(String type) {
|
||||
return dsl().createType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* @see DSLContext#createType(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static CreateTypeStep createType(Name type) {
|
||||
return dsl().createType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropType(String type) {
|
||||
return dsl().dropType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropType(Name type) {
|
||||
return dsl().dropType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(String...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropType(String... type) {
|
||||
return dsl().dropType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Name...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropType(Name... type) {
|
||||
return dsl().dropType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropType(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropType(Collection<?> type) {
|
||||
return dsl().dropType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(String)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropTypeIfExists(String type) {
|
||||
return dsl().dropTypeIfExists(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Name)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropTypeIfExists(Name type) {
|
||||
return dsl().dropTypeIfExists(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(String...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropTypeIfExists(String... type) {
|
||||
return dsl().dropTypeIfExists(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Name...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropTypeIfExists(Name... type) {
|
||||
return dsl().dropTypeIfExists(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* @see DSL#dropTypeIfExists(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static DropTypeStep dropTypeIfExists(Collection<?> type) {
|
||||
return dsl().dropTypeIfExists(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSL <code>ALTER TABLE</code> statement.
|
||||
*
|
||||
@ -12606,6 +12730,42 @@ public class DSL {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a qualified type, given its type name.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static Type<?> type(@Stringly.Name String name) {
|
||||
return type(name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a qualified type, given its type name.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static Type<?> type(Name name) {
|
||||
return type(name, SQLDataType.OTHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a qualified type, given its type name.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static <T> Type<T> type(@Stringly.Name String name, DataType<T> type) {
|
||||
return type(name(name), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a qualified type, given its type name.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, YUGABYTEDB })
|
||||
public static <T> Type<T> type(Name name, DataType<T> type) {
|
||||
return new TypeImpl<>(name, CommentImpl.NO_COMMENT, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a qualified table, given its table name.
|
||||
* <p>
|
||||
|
||||
@ -108,7 +108,6 @@ import org.jooq.ConnectionProvider;
|
||||
import org.jooq.ConnectionRunnable;
|
||||
import org.jooq.ContextTransactionalCallable;
|
||||
import org.jooq.ContextTransactionalRunnable;
|
||||
import org.jooq.CreateTypeStep;
|
||||
import org.jooq.CreateViewAsStep;
|
||||
import org.jooq.Cursor;
|
||||
import org.jooq.DDLExportConfiguration;
|
||||
@ -118,7 +117,6 @@ import org.jooq.DataType;
|
||||
import org.jooq.DeleteQuery;
|
||||
import org.jooq.DeleteUsingStep;
|
||||
import org.jooq.Domain;
|
||||
import org.jooq.DropTypeStep;
|
||||
import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Explain;
|
||||
@ -234,6 +232,7 @@ import org.jooq.TransactionProvider;
|
||||
import org.jooq.TransactionalCallable;
|
||||
import org.jooq.TransactionalPublishable;
|
||||
import org.jooq.TransactionalRunnable;
|
||||
import org.jooq.Type;
|
||||
import org.jooq.UDT;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.UpdatableRecord;
|
||||
@ -3418,6 +3417,21 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateTypeStep createType(@Stringly.Name String type) {
|
||||
return new CreateTypeImpl(configuration(), DSL.type(DSL.name(type)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateTypeStep createType(Name type) {
|
||||
return new CreateTypeImpl(configuration(), DSL.type(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateTypeStep createType(Type<?> type) {
|
||||
return new CreateTypeImpl(configuration(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.CreateSchemaFinalStep createSchema(@Stringly.Name String schema) {
|
||||
@ -3772,6 +3786,76 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropType(@Stringly.Name String types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropType(Name types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropType(Type<?> types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(types), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropType(String... types) {
|
||||
return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropType(Name... types) {
|
||||
return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropType(Type<?>... types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(types), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropType(Collection<? extends Type<?>> types) {
|
||||
return new DropTypeImpl(configuration(), new QueryPartList<>(types), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropTypeIfExists(@Stringly.Name String types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropTypeIfExists(Name types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(DSL.type(types)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropTypeIfExists(Type<?> types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(types), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropTypeIfExists(String... types) {
|
||||
return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropTypeIfExists(Name... types) {
|
||||
return new DropTypeImpl(configuration(), Tools.map(types, e -> DSL.type(e)), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropTypeIfExists(Type<?>... types) {
|
||||
return new DropTypeImpl(configuration(), Arrays.asList(types), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropTypeStep dropTypeIfExists(Collection<? extends Type<?>> types) {
|
||||
return new DropTypeImpl(configuration(), new QueryPartList<>(types), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.DropViewFinalStep dropView(@Stringly.Name String view) {
|
||||
@ -4199,66 +4283,6 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
return new CreateViewImpl<>(configuration(), view, fieldNameFunction, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateTypeStep createType(String type) {
|
||||
return createType(name(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateTypeStep createType(Name type) {
|
||||
return new CreateTypeImpl(configuration(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropType(String type) {
|
||||
return dropType(name(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropType(Name type) {
|
||||
return dropType(Arrays.asList(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropType(String... type) {
|
||||
return dropType(Tools.names(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropType(Name... type) {
|
||||
return dropType(Arrays.asList(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropType(Collection<?> type) {
|
||||
return new DropTypeImpl(configuration(), type, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropTypeIfExists(String type) {
|
||||
return dropTypeIfExists(name(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropTypeIfExists(Name type) {
|
||||
return dropTypeIfExists(Arrays.asList(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropTypeIfExists(String... type) {
|
||||
return dropTypeIfExists(Tools.names(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropTypeIfExists(Name... type) {
|
||||
return dropTypeIfExists(Arrays.asList(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropTypeStep dropTypeIfExists(Collection<?> type) {
|
||||
return new DropTypeImpl(configuration(), type, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlterTableStep alterTable(String table) {
|
||||
return alterTable(name(table));
|
||||
|
||||
@ -37,71 +37,94 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Keywords.K_CASCADE;
|
||||
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 static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Internal.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.impl.Tools.ExtendedDataKey.*;
|
||||
import static org.jooq.impl.Tools.SimpleDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DropTypeFinalStep;
|
||||
import org.jooq.DropTypeStep;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.*;
|
||||
import org.jooq.Function1;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.impl.QOM.Cascade;
|
||||
import org.jooq.impl.QOM.DropType;
|
||||
import org.jooq.impl.QOM.UnmodifiableList;
|
||||
import org.jooq.QueryPart;
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.Record;
|
||||
import org.jooq.conf.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unused" })
|
||||
final class DropTypeImpl
|
||||
extends
|
||||
AbstractDDLQuery
|
||||
implements
|
||||
QOM.DropType,
|
||||
DropTypeStep,
|
||||
DropType
|
||||
DropTypeFinalStep
|
||||
{
|
||||
|
||||
private final QueryPartList<Name> type;
|
||||
private final boolean ifExists;
|
||||
private Cascade cascade;
|
||||
final QueryPartListView<? extends Type<?>> types;
|
||||
final boolean ifExists;
|
||||
Cascade cascade;
|
||||
|
||||
DropTypeImpl(Configuration configuration, Collection<?> type, boolean ifExists) {
|
||||
super(configuration);
|
||||
|
||||
this.type = new QueryPartList<>(Tools.names(type));
|
||||
this.ifExists = ifExists;
|
||||
DropTypeImpl(
|
||||
Configuration configuration,
|
||||
Collection<? extends Type<?>> types,
|
||||
boolean ifExists
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
types,
|
||||
ifExists,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
DropTypeImpl(
|
||||
Configuration configuration,
|
||||
Collection<? extends Type<?>> types,
|
||||
boolean ifExists,
|
||||
Cascade cascade
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.types = new QueryPartList<>(types);
|
||||
this.ifExists = ifExists;
|
||||
this.cascade = cascade;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final DropTypeFinalStep cascade() {
|
||||
public final DropTypeImpl cascade() {
|
||||
this.cascade = Cascade.CASCADE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DropTypeFinalStep restrict() {
|
||||
public final DropTypeImpl restrict() {
|
||||
this.cascade = Cascade.RESTRICT;
|
||||
return this;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
@ -110,20 +133,23 @@ implements
|
||||
if (ifExists)
|
||||
ctx.sql(' ').visit(K_IF_EXISTS);
|
||||
|
||||
ctx.sql(' ').visit(type);
|
||||
ctx.sql(' ').visit(types);
|
||||
|
||||
if (cascade == Cascade.CASCADE)
|
||||
ctx.sql(' ').visit(K_CASCADE);
|
||||
else if (cascade == Cascade.RESTRICT)
|
||||
ctx.sql(' ').visit(K_RESTRICT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final UnmodifiableList<? extends Name> $names() {
|
||||
return QOM.unmodifiable(type);
|
||||
public final UnmodifiableList<? extends Type<?>> $types() {
|
||||
return QOM.unmodifiable(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -136,6 +162,30 @@ implements
|
||||
return cascade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.DropType $types(Collection<? extends Type<?>> newValue) {
|
||||
return $constructor().apply(newValue, $ifExists(), $cascade());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.DropType $ifExists(boolean newValue) {
|
||||
return $constructor().apply($types(), newValue, $cascade());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.DropType $cascade(Cascade newValue) {
|
||||
return $constructor().apply($types(), $ifExists(), newValue);
|
||||
}
|
||||
|
||||
public final Function3<? super Collection<? extends Type<?>>, ? super Boolean, ? super Cascade, ? extends QOM.DropType> $constructor() {
|
||||
return (a1, a2, a3) -> new DropTypeImpl(configuration(), (Collection<? extends Type<?>>) a1, a2, a3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3148,7 +3148,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
;
|
||||
else if (parseKeywordIf("TYPE"))
|
||||
return parseCascadeRestrictIf(
|
||||
parseIfExists(this::parseIdentifiers, dsl::dropTypeIfExists, dsl::dropType),
|
||||
parseIfExists(this::parseIdentifiers,
|
||||
n -> dsl.dropTypeIfExists(n.toArray(EMPTY_NAME)),
|
||||
n -> dsl.dropType(n.toArray(EMPTY_NAME))
|
||||
),
|
||||
DropTypeStep::cascade,
|
||||
DropTypeStep::restrict
|
||||
);
|
||||
@ -5123,7 +5126,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
else
|
||||
values = new ArrayList<>();
|
||||
|
||||
return dsl.createType(name).asEnum(values);
|
||||
return dsl.createType(name).asEnum(values.toArray(EMPTY_STRING));
|
||||
}
|
||||
|
||||
private final Index parseIndexSpecification(Table<?> table) {
|
||||
|
||||
@ -47,14 +47,12 @@ import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collector;
|
||||
|
||||
@ -113,7 +111,6 @@ import org.jooq.Param;
|
||||
import org.jooq.Parameter;
|
||||
import org.jooq.Privilege;
|
||||
// ...
|
||||
import org.jooq.QuantifiedSelect;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
@ -138,14 +135,13 @@ import org.jooq.Table;
|
||||
import org.jooq.TableElement;
|
||||
import org.jooq.TableLike;
|
||||
// ...
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.Type;
|
||||
// ...
|
||||
import org.jooq.WindowDefinition;
|
||||
import org.jooq.WindowSpecification;
|
||||
import org.jooq.XML;
|
||||
import org.jooq.XMLAttributes;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.impl.QOM.UCommutativeOperator;
|
||||
import org.jooq.types.DayToSecond;
|
||||
// ...
|
||||
|
||||
@ -630,33 +626,6 @@ public final class QOM {
|
||||
@NotNull DeleteReturning<?> $returning(Collection<? extends SelectFieldOrAsterisk> returning);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
public /*sealed*/ interface CreateType
|
||||
extends
|
||||
DDLQuery
|
||||
/*permits
|
||||
CreateTypeImpl*/
|
||||
{
|
||||
@NotNull Name $name();
|
||||
@NotNull UnmodifiableList<? extends Field<String>> $values();
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*/
|
||||
public /*sealed*/ interface DropType
|
||||
extends
|
||||
DDLQuery
|
||||
/*permits
|
||||
DropTypeImpl*/
|
||||
{
|
||||
@NotNull UnmodifiableList<? extends Name> $names();
|
||||
boolean $ifExists();
|
||||
@Nullable Cascade $cascade();
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE VIEW</code> statement.
|
||||
*/
|
||||
@ -2288,6 +2257,23 @@ public final class QOM {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The <code>CREATE TYPE</code> statement.
|
||||
*/
|
||||
public /*sealed*/ interface CreateType
|
||||
extends
|
||||
DDLQuery
|
||||
//permits
|
||||
// CreateTypeImpl
|
||||
{
|
||||
@NotNull Type<?> $type();
|
||||
@NotNull UnmodifiableList<? extends Field<String>> $values();
|
||||
@CheckReturnValue
|
||||
@NotNull CreateType $type(Type<?> type);
|
||||
@CheckReturnValue
|
||||
@NotNull CreateType $values(Collection<? extends Field<String>> values);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>CREATE SCHEMA</code> statement.
|
||||
@ -2529,6 +2515,26 @@ public final class QOM {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The <code>DROP TYPE</code> statement.
|
||||
*/
|
||||
public /*sealed*/ interface DropType
|
||||
extends
|
||||
DDLQuery
|
||||
//permits
|
||||
// DropTypeImpl
|
||||
{
|
||||
@NotNull UnmodifiableList<? extends Type<?>> $types();
|
||||
boolean $ifExists();
|
||||
@Nullable Cascade $cascade();
|
||||
@CheckReturnValue
|
||||
@NotNull DropType $types(Collection<? extends Type<?>> types);
|
||||
@CheckReturnValue
|
||||
@NotNull DropType $ifExists(boolean ifExists);
|
||||
@CheckReturnValue
|
||||
@NotNull DropType $cascade(Cascade cascade);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>DROP VIEW</code> statement.
|
||||
|
||||
64
jOOQ/src/main/java/org/jooq/impl/TypeImpl.java
Normal file
64
jOOQ/src/main/java/org/jooq/impl/TypeImpl.java
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: https://www.jooq.org/legal/licensing
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import org.jooq.Comment;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Type;
|
||||
import org.jooq.impl.QOM.UNotYetImplemented;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class TypeImpl<T> extends AbstractTypedNamed<T> implements Type<T>, UNotYetImplemented {
|
||||
|
||||
TypeImpl(Name name, Comment comment, DataType<T> type) {
|
||||
super(name, comment, type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(getQualifiedName());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user