[#6162] Deprecate plain SQL DSL.sequence(String) constructors
This commit is contained in:
parent
8970be8275
commit
294b06ac1e
@ -56,33 +56,43 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
public interface Sequence<T extends Number> extends QueryPart {
|
||||
|
||||
/**
|
||||
* Get the sequence name
|
||||
* Get the sequence name.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* The qualified name of this sequence.
|
||||
*/
|
||||
Name getQualifiedName();
|
||||
|
||||
/**
|
||||
* The unqualified name of this sequence.
|
||||
*/
|
||||
Name getUnqualifiedName();
|
||||
|
||||
/**
|
||||
* Get the sequence catalog.
|
||||
*/
|
||||
Catalog getCatalog();
|
||||
|
||||
/**
|
||||
* Get the sequence schema
|
||||
* Get the sequence schema.
|
||||
*/
|
||||
Schema getSchema();
|
||||
|
||||
/**
|
||||
* Get the sequence data type
|
||||
* Get the sequence data type.
|
||||
*/
|
||||
DataType<T> getDataType();
|
||||
|
||||
/**
|
||||
* Get the current value of this sequence
|
||||
* Get the current value of this sequence.
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD, H2, POSTGRES })
|
||||
Field<T> currval();
|
||||
|
||||
/**
|
||||
* Increment the sequence and get the next value
|
||||
* Increment the sequence and get the next value.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
Field<T> nextval();
|
||||
|
||||
@ -8642,7 +8642,9 @@ public class DSL {
|
||||
* @param sql The SQL
|
||||
* @return A field wrapping the plain SQL
|
||||
* @see SQL
|
||||
* @deprecated - 3.10 - [#6162] - Use {@link #sequence(Name)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@PlainSQL
|
||||
public static Sequence<BigInteger> sequence(String sql) {
|
||||
@ -8661,7 +8663,9 @@ public class DSL {
|
||||
* @param type The field type
|
||||
* @return A field wrapping the plain SQL
|
||||
* @see SQL
|
||||
* @deprecated - 3.10 - [#6162] - Use {@link #sequence(Name, Class)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@PlainSQL
|
||||
public static <T extends Number> Sequence<T> sequence(String sql, Class<T> type) {
|
||||
@ -8680,11 +8684,14 @@ public class DSL {
|
||||
* @param type The field type
|
||||
* @return A field wrapping the plain SQL
|
||||
* @see SQL
|
||||
* @deprecated - 3.10 - [#6162] - Use {@link #sequence(Name, DataType)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES })
|
||||
@PlainSQL
|
||||
public static <T extends Number> Sequence<T> sequence(String sql, DataType<T> type) {
|
||||
return new SequenceImpl<T>(sql, null, type, true);
|
||||
return new SequenceImpl<T>(using(new DefaultConfiguration()).parser().parseName(sql), null, type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -48,6 +48,7 @@ import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Schema;
|
||||
@ -69,27 +70,40 @@ public class SequenceImpl<T extends Number> extends AbstractQueryPart implements
|
||||
private static final long serialVersionUID = 6224349401603636427L;
|
||||
private static final Clause[] CLAUSES = { SEQUENCE, SEQUENCE_REFERENCE };
|
||||
|
||||
final String name;
|
||||
final boolean nameIsPlainSQL;
|
||||
final Name name;
|
||||
final Schema schema;
|
||||
final DataType<T> type;
|
||||
|
||||
public SequenceImpl(String name, Schema schema, DataType<T> type) {
|
||||
this(name, schema, type, false);
|
||||
this(DSL.name(name), schema, type);
|
||||
}
|
||||
|
||||
SequenceImpl(String name, Schema schema, DataType<T> type, boolean nameIsPlainSQL) {
|
||||
public SequenceImpl(Name name, Schema schema, DataType<T> type) {
|
||||
this.name = name;
|
||||
this.schema = schema;
|
||||
this.schema =
|
||||
schema != null
|
||||
? schema
|
||||
: name.qualified()
|
||||
? DSL.schema(name.qualifier())
|
||||
: null;
|
||||
this.type = type;
|
||||
this.nameIsPlainSQL = nameIsPlainSQL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getName() {
|
||||
return name.last();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Name getQualifiedName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Name getUnqualifiedName() {
|
||||
return name.unqualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Catalog getCatalog() {
|
||||
return getSchema() == null ? null : getSchema().getCatalog();
|
||||
@ -244,10 +258,8 @@ public class SequenceImpl<T extends Number> extends AbstractQueryPart implements
|
||||
|
||||
if (asStringLiterals)
|
||||
ctx.visit(inline(name));
|
||||
else if (nameIsPlainSQL)
|
||||
ctx.sql(name);
|
||||
else
|
||||
ctx.literal(name);
|
||||
ctx.visit(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user