This commit is contained in:
lukaseder 2017-05-03 11:40:25 +02:00
parent 3605697b8d
commit f33e2fe982
3 changed files with 15 additions and 37 deletions

View File

@ -56,43 +56,33 @@ 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();

View File

@ -8691,7 +8691,7 @@ public class DSL {
@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>(using(new DefaultConfiguration()).parser().parseName(sql), null, type);
return new SequenceImpl<T>(sql, null, type, true);
}
/**

View File

@ -48,7 +48,6 @@ 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;
@ -70,40 +69,27 @@ public class SequenceImpl<T extends Number> extends AbstractQueryPart implements
private static final long serialVersionUID = 6224349401603636427L;
private static final Clause[] CLAUSES = { SEQUENCE, SEQUENCE_REFERENCE };
final Name name;
final String name;
final boolean nameIsPlainSQL;
final Schema schema;
final DataType<T> type;
public SequenceImpl(String name, Schema schema, DataType<T> type) {
this(DSL.name(name), schema, type);
this(name, schema, type, false);
}
public SequenceImpl(Name name, Schema schema, DataType<T> type) {
SequenceImpl(String name, Schema schema, DataType<T> type, boolean nameIsPlainSQL) {
this.name = name;
this.schema =
schema != null
? schema
: name.qualified()
? DSL.schema(name.qualifier())
: null;
this.schema = schema;
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();
@ -258,8 +244,10 @@ public class SequenceImpl<T extends Number> extends AbstractQueryPart implements
if (asStringLiterals)
ctx.visit(inline(name));
else if (nameIsPlainSQL)
ctx.sql(name);
else
ctx.visit(name);
ctx.literal(name);
}
@Override